Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devtools can't open on Electron #273

Closed
major697 opened this issue Mar 11, 2024 · 5 comments
Closed

Devtools can't open on Electron #273

major697 opened this issue Mar 11, 2024 · 5 comments
Labels
need reproduction Reproduction is needed

Comments

@major697
Copy link

major697 commented Mar 11, 2024

I have app in Electron, Vite and Vue3.

node: v20.11.1
npm: 10.2.4
MacOS: 14.4 (23E214)

This is my dependencies:

"dependencies": {
    "axios": "^1.6.7",
    "dayjs": "^1.11.10",
    "dotenv": "^16.4.5",
    "electron-log": "^5.1.1",
    "electron-updater": "^6.1.8",
    "jwt-decode": "^4.0.0",
    "node-machine-id": "^1.1.12",
    "pinia": "^2.1.7",
    "socket.io-client": "^4.7.4",
    "vue": "^3.4.21",
    "vue-router": "^4.3.0"
  },
  "devDependencies": {
    "@types/node": "^20.11.25",
    "@typescript-eslint/eslint-plugin": "^7.1.1",
    "@typescript-eslint/parser": "^7.1.1",
    "@vitejs/plugin-vue": "^5.0.4",
    "@vue/eslint-config-prettier": "^9.0.0",
    "@vue/eslint-config-typescript": "^12.0.0",
    "autoprefixer": "^10.4.18",
    "electron": "^29.1.0",
    "electron-builder": "^24.13.3",
    "eslint": "^8.57.0",
    "eslint-plugin-prettier": "^5.1.3",
    "eslint-plugin-vue": "^9.22.0",
    "husky": "^9.0.11",
    "lint-staged": "^15.2.2",
    "postcss": "^8.4.35",
    "prettier": "^3.2.5",
    "sass": "^1.71.1",
    "tailwindcss": "^3.4.1",
    "typescript": "^5.3.3",
    "vite": "^5.1.5",
    "vite-plugin-electron": "^0.28.2",
    "vite-plugin-electron-renderer": "^0.14.5",
    "vite-plugin-vue-devtools": "^7.0.16",
    "vue-tsc": "^2.0.5"
  },
  "overrides": {
    "vite-plugin-electron": {
      "electron": "$electron"
    }
  }

When I try open Devtools, I have an error in console:
EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'unsafe-inline'".

Inside index.html file I have:
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
Whe I change this to this:
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-eval';" />

The Electorn return error:
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval'". Either the 'unsafe-inline' keyword, a hash ('sha256-oQFZCLbDrsnK+JwZN6u488PGfhj52jozs93UXp01Puo='), or a nonce ('nonce-...') is required to enable inline execution.

I back to 7.0.15, but still I have this same errors.

@webfansplz
Copy link
Member

Can you provide a mini repo? thanks 🙏

@webfansplz webfansplz added the need reproduction Reproduction is needed label Mar 12, 2024
@alexzhang1030
Copy link
Collaborator

Related #265

#268 fixed this issue, you can try again after it is published.

@webfansplz
Copy link
Member

Related #265

#268 fixed this issue, you can try again after it is published.

image

I also think this is the reason, so I think if we still have this issue in v7.0.15, we need a reproduction @major697 .

@webfansplz
Copy link
Member

@major697 Hi, can you upgrade to the latest version and try again?

@major697
Copy link
Author

major697 commented Mar 25, 2024

I have updated to the latest version (7.0.20). Works fine, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need reproduction Reproduction is needed
Projects
None yet
Development

No branches or pull requests

3 participants