fix: cors issues from preview fixed by changing embedder policies #1056
+23
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reason for Change
Issue reported here:
https://thinktank.ottomator.ai/t/cors-proxy-needed/4096/6
leex279
shared an example of OpenStreetMap.I tested that it works in
bolt.new
but not inDIY
.Difference Identified
The issue was traced to the Cross-Origin Embedder Policy (COEP):
DIY (hosted from
local-corp.webcontainer-api.io
)cross-origin-embedder-policy: require-corp
This policy mandates that all resources loaded by the iframe must explicitly allow cross-origin embedding by setting appropriate headers (e.g.,
Cross-Origin-Resource-Policy
orAccess-Control-Allow-Origin
).If the tile server (
a.tile.openstreetmap.org
) doesn't fully comply with this policy, the browser blocks the resource.Bolt.New (hosted from
local-credentialless.webcontainer-api.io
)cross-origin-embedder-policy: credentialless
This policy is less restrictive and doesn't require the same level of resource permissions. It works better with services like OpenStreetMap that rely on permissive
Access-Control-Allow-Origin: *
.Solution
I explored the differences and found two places where this policy could be changed.
After making these changes, it works correctly.
Before
After