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

fix(vite): add configured headers for devtool-related response #710

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nighca
Copy link

@nighca nighca commented Nov 22, 2024

server.headers in vite configuration is now ignored by __devtool__ related requests, which are handled by sirv.

This PR applies server.headers in vite configuration to these requests' response.

This PR fixes #565.

Copy link

netlify bot commented Nov 22, 2024

Deploy Preview for vue-devtools-docs canceled.

Name Link
🔨 Latest commit 5294d4b
🔍 Latest deploy log https://app.netlify.com/sites/vue-devtools-docs/deploys/673ffff5aa8e8d00085adcd3

Copy link

pkg-pr-new bot commented Nov 22, 2024

Open in Stackblitz

@vue/devtools-applet

pnpm add https://pkg.pr.new/@vue/devtools-applet@710

@vue/devtools-core

pnpm add https://pkg.pr.new/@vue/devtools-core@710

@vue/devtools

pnpm add https://pkg.pr.new/@vue/devtools@710

@vue/devtools-api

pnpm add https://pkg.pr.new/@vue/devtools-api@710

@vue/devtools-kit

pnpm add https://pkg.pr.new/@vue/devtools-kit@710

vite-plugin-vue-devtools

pnpm add https://pkg.pr.new/vite-plugin-vue-devtools@710

commit: 5294d4b

@webfansplz
Copy link
Member

@nighca I tested this with use case #565, but the issue still seems to exist. You can reproduce it with pnpm run build && pnpm run play

@nighca
Copy link
Author

nighca commented Nov 30, 2024

@nighca I tested this with use case #565, but the issue still seems to exist. You can reproduce it with pnpm run build && pnpm run play

@webfansplz The issue is fixed as I confirmed by following these steps:

  1. Checkout code from my branch: https://github.com/nighca/vuejs-devtools/tree/fix-devtool-header

  2. Configure packages/playground/basic/ with Cross-Origin-* headers:

    server: {
      port: 3000,
      headers: {
        'Cross-Origin-Embedder-Policy': 'require-corp',
        'Cross-Origin-Opener-Policy': 'same-origin',
      },
    },
  3. Run pnpm run build && pnpm run play and open http://localhost:3000. The devtool page can loads correctly.

  4. Checkout branch main

  5. Run pnpm run build && pnpm run play and open http://localhost:3000. Now the devtool page fails to load, showing "localhost refused to connect."

While during testing, I noticed that sometimes the script (pnpm run build && pnpm run play) did not update the built result (packages/vite/dist/vite.mjs) as expected, likely due to build caching. This may explain why you still encountered the "devtool-failed-to-load" issue. You may check the content of packages/vite/dist/vite.mjs to verify.

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

Successfully merging this pull request may close these issues.

Vite integration iframe content fetch connection refused with Cross Origin Embedder Policy applied
2 participants