• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Pruebas Online
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

780
Vistas
why net::ERR_UNSAFE_REDIRECT in chrome when redirecting to 'data:' links?

I developing new extension for google chrome browser, and now I stacked this task:

  1. Use chrome.webRequest.onBeforeRequest to intercept the request.
  2. Prevent the request from executing (but not completing its error) by redirecting to a link like data:text/javascript;charset=utf-8, (empty js).

developer chrome docs says, that I can do it like this:

chrome.webRequest.onBeforeRequest.addListener((details)=>{
    //some if statments and etc...

    return { redirectUrl: 'data:text/javascript;charset=utf-8,'}

}, {urls: ["<all_urls>"]}, ["blocking"]);

And I am very sure it's allowed to redirect to data: links like this, because of this docs:

redirectUrl Only used as a response to the onBeforeRequest and onHeadersReceived events. If set, the original request is prevented from being sent/completed and is instead redirected to the given URL. Redirections to non-HTTP schemes such as data: are allowed. Redirects initiated by a redirect action use the original request method for the redirect, with one exception: If the redirect is initiated at the onHeadersReceived stage, then the redirect will be issued using the GET method. Redirects from URLs with ws:// and wss:// schemes are ignored.

from this documentations

But when I tries to do this, I see this error in console: net:ERR_UNSAFE_REDIRECT

So, what is my problem?

P.S. in my mainfest.json I have this permisions:

"permissions": [ "webNavigation", "tabs", "webRequest", "webRequestBlocking", "<all_urls>", "notifications", "storage", "contextMenus", "unlimitedStorage" ],
almost 3 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda