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: cors issues from preview fixed by changing embedder policies #1056

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

Conversation

wonderwhy-er
Copy link
Collaborator

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 in DIY.

Difference Identified

The issue was traced to the Cross-Origin Embedder Policy (COEP):

  1. DIY (hosted from local-corp.webcontainer-api.io)

    • Header: cross-origin-embedder-policy: require-corp
    • Impact:
      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 or Access-Control-Allow-Origin).
      If the tile server (a.tile.openstreetmap.org) doesn't fully comply with this policy, the browser blocks the resource.
  2. Bolt.New (hosted from local-credentialless.webcontainer-api.io)

    • Header: cross-origin-embedder-policy: credentialless
    • Impact:
      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

image

After

Screenshot 2025-01-09 at 10 44 35

@wonderwhy-er wonderwhy-er changed the title Fix cors problems fix: cors issues from preview fixed by changing embedder policies Jan 9, 2025
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.

1 participant