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

feat(electron-esbuild): remove COEP headers in document load #17

Merged
merged 2 commits into from
Jun 2, 2021
Merged

feat(electron-esbuild): remove COEP headers in document load #17

merged 2 commits into from
Jun 2, 2021

Conversation

josteph
Copy link
Contributor

@josteph josteph commented May 24, 2021

Fixes #12

Scenario:

  1. HTML file, when retrieved, will fall through if (req.url === '/' || req.url === '') block resulting in the CORS header being set for the whole document
    image

  2. Let's say we want to add new worker file, which we need to add a new entryPoints in esbuild.renderer.config.js in order to bundle the worker file. Example: https://github.com/josteph/josteph-electron-esbuild/blob/912a2e9243c938d261fe91713b48debfe9ece4c3/config/esbuild.renderer.config.js

  3. Project structure now:
    image

Expected
Able to resolve http://localhost:9080/worker.js

Actual Behaviour
Blocked due these headers being set in HTML load:

res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp')
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin')

image
image
image

@Kiyozz
Copy link
Owner

Kiyozz commented May 24, 2021

I'm not sure what exactly this option does. Can you clarify for me? And why this fixe static files?

@josteph
Copy link
Contributor Author

josteph commented May 25, 2021

This doesn't fix static files. But it fixes if you try to transpile/compile more than one entryPoints in esbuild.
https://github.com/josteph/josteph-electron-esbuild/blob/912a2e9243c938d261fe91713b48debfe9ece4c3/config/esbuild.renderer.config.js

I've been playing around with it and chrome actually blocked the request by telling me about appending those specific headers into the response. Since it is localhost i think there would be no concern..

Let me know if this doesn't make sense.


About static files, i think you want to refer to buildResources option instead?

@Kiyozz
Copy link
Owner

Kiyozz commented May 25, 2021

By static files, I means files that are available on "/". If you want to add any images, or untranspiled js, css, etc. Like a server public path.

Your PR doesn't seem to fix the linked issue (#13), but another problem that is multiple esbuild renderer entrypoints. Maybe you could create a new issue more detailed?

@josteph
Copy link
Contributor Author

josteph commented May 25, 2021

@Kiyozz I have updated the PR description and this actually fixes #12 issue.
About COEP, the default value is unsafe-none.

@josteph josteph changed the title feat(electron-esbuild): enable cross origin for all proxy in esbuild dev feat(electron-esbuild): remove COEP headers in document load May 25, 2021
@josteph
Copy link
Contributor Author

josteph commented May 28, 2021

Hi, is there any other concern for removing COEP headers in development mode?

@Kiyozz
Copy link
Owner

Kiyozz commented May 28, 2021

Hey josteph, thanks for your changes. I forgot to answer, I want to make a few tests before complete the pr but I did not find the time.

I think their is no problem!

@Kiyozz
Copy link
Owner

Kiyozz commented Jun 2, 2021

Thanks you for your work.

@Kiyozz Kiyozz merged commit 8c31429 into Kiyozz:main Jun 2, 2021
@josteph
Copy link
Contributor Author

josteph commented Jun 2, 2021

No, thank you for the great package!

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.

Cors overly restrictive ?
2 participants