thheller / shadow-cljs

ClojureScript compilation made easy
https://github.com/thheller/shadow-cljs
Eclipse Public License 1.0
2.23k stars 173 forks source link

Issue with CORS in dev HTTP server since 2.25.10 release #1164

Closed sbenhaim closed 7 months ago

sbenhaim commented 7 months ago

When loading JS served by the dev HTTP server from an Electron app, I get the following since 2.25.10:

Access to script at 'http://localhost:8605/saber.js' from origin 'app://obsidian.md' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Worked in version 2.25.9.

I suspect it has something to do with this commit: https://github.com/thheller/shadow-cljs/commit/a0c8695453fe0da48d20bc3029d5e9c26acaea45

I attempted adding headers using :push-state/headers to :dev-http config, but had no effect.

:dev-http {8605 {:root "cljs-out"
                 :push-state/headers {"content-type" "text/html; charset=utf-8"
                                      "Access-Control-Allow-Origin" "*"}}}
thheller commented 7 months ago

Oops, yeah that wasn't intentional. Fixed in 2.26.2.

sbenhaim commented 7 months ago

Confirmed, thanks!