crxjs / chrome-extension-tools

Bundling Chrome Extensions can be pretty complex. It doesn't have to be.
https://crxjs.dev/vite-plugin
2.75k stars 182 forks source link

The script resource is behind a redirect, which is disallowed #728

Open fduayer opened 1 year ago

fduayer commented 1 year ago

Build tool

Vite

Where do you see the problem?

Describe the bug

I get the message described in the title right after loading the 'dist' folder into chrome. The error message appears in the extension's card 'Error' button.

If I comment out the two imports from service-worker-loader.js, the error disappears:

// import 'http://localhost:5173/@vite/env';
// import 'http://localhost:5173/@crx/client-worker';

To be clear, I get this error before doing anything inside the project, just right after npm init vite@latest followed by npm i @crxjs/vite-plugin@beta -D. The same problem occurs when using vite 2.

error_01

error_02

Has anybody else experienced this issue?

Reproduction

No repo.

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
    Memory: 9.67 GB / 15.94 GB
Binaries:
    Node: 18.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.16.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 9.6.5 - ~\AppData\Roaming\npm\npm.CMD
Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (113.0.1774.57)

Severity

annoyance

zisra commented 1 year ago

Same issue

Toumash commented 1 year ago

Could not reproduce - works just fine. What versions of vite, @crxjs/vite-plugin are you using?

Working code (branch service-worker) https://github.com/Toumash/react-extension-vite-template/tree/service-worker-sample

image

No errors image

avin commented 1 year ago

have the same error, but it works anyway

carl-jin commented 10 months ago

I recently encountered this issue where Chrome automatically redirects http://localhost:5173 to https://localhost:5173. This error occurred because of my other Vite projects using the https protocol.

To resolve this, you just need to go to chrome://net-internals/#hsts and clear the "Delete domain security policies" option. Enter "localhost" in the "Domain" field and click "delete".

image