-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
support customer http response header for CSP #2766
Comments
Thanks for using Wails and opening this. You can achieve this by using a custom AssetServer middleware that injects those two headers. There's also a discord thread that has more information about exactly your use-case: https://discord.com/channels/1042734330029547630/1115379135464874095 |
thank you very much! I will have a try |
had a try, but it seems it does not set the response header
2: CSP
build the project and run it again < HTTP/1.1 200 OK |
It seems like your middleware does not call the original handler, it should look like this and call the original handler at the end. func CSP(handler http.Handler) http.Handler {
return http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
// https://github.com/rhysd/vim.wasm/issues/45
w.Header().Set("Cross-Origin-Opener-Policy", "same-origin")
w.Header().Set("Cross-Origin-Embedder-Policy", "require-corp")
fmt.Println("def")
fmt.Println(w.Header().Get("Cross-Origin-Opener-Policy"))
handler.ServeHTTP(w, r) // Call the original request chain
}
)
}
Which address and port did you use to do the curl? |
Description
I am building an app base on https://github.com/rhysd/vim.wasm, which depends on the SharedArrayBuffer and Atomics,
I ran into below error with csp exception.
react-dom.development.js:22839 Uncaught ReferenceError: SharedArrayBuffer is not defined at new VimWorker (vimwasm.js:1:1638) at new VimWasm (vimwasm.js:1:13290) at Vim.tsx:74:13 at commitHookEffectListMount (react-dom.development.js:23150:26) at commitPassiveMountOnFiber (react-dom.development.js:24926:13) at commitPassiveMountEffects_complete (react-dom.development.js:24891:9) at commitPassiveMountEffects_begin (react-dom.development.js:24878:7) at commitPassiveMountEffects (react-dom.development.js:24866:3) at flushPassiveEffectsImpl (react-dom.development.js:27039:3)
react-native has the same issue, facebook/create-react-app#10210 (comment)
seems the solution works by adding two
http response header
Cross-Origin-Opener-Policy: same-origin Cross-Origin-Embedder-Policy: require-corp
how to achieve this in wails?
To Reproduce
1: create a simple wails app with react-ts template
2: copy source react-vim into the project.
3: run the project get the result.
Expected behaviour
support custome http response headers .
Screenshots
No response
Attempted Fixes
No response
System Details
Additional context
No response
The text was updated successfully, but these errors were encountered: