Open stevezhu opened 1 year ago
When is it expected to be repaired
@stevezhu Found a solution?
I included a fix to this issue, if it's not merged, you can link it locally, just make these changes:
async function sendToServer(url: URL): Promise<Response> {
if (url.href.includes('/_favicon/')) {
const response = await fetch(url.href)
return new Response(response.body, {
headers: {
'Content-Type': response.headers.get('Content-Type') ?? 'text/javascript',
},
})
}
// change the url to point to the dev server
url.protocol = 'http:'
url.host = 'localhost'
url.port = __SERVER_PORT__
// add a timestamp to force Chrome to do a new request
url.searchParams.set('t', Date.now().toString())
// URLSearchParams adds "=" to every empty param & vite doesn't like it
const response = await fetch(url.href.replace(/=$|=(?=&)/g, ''))
// circumvent extension CSP by creating response from extension origin
return new Response(response.body, {
headers: {
'Content-Type': response.headers.get('Content-Type') ?? 'text/javascript',
},
})
}
The problem still exists.
Build tool
Vite
Where do you see the problem?
Describe the bug
I'm attempting to use the
/_favicon/
api from chrome manifest v3 shown here: https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/api/faviconIt seems that due to the hmr client worker capturing all requests during dev, the requests to
/_favicon/
are also being captured instead of being handled by chrome.Reproduction
Use https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/api/favicon with
@crxjs/vite-plugin
in dev mode.Logs
Failed request (when client worker is capturing requests):
Expected successful request:
System Info
Severity
annoyance