question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] New default maps service cached policy causing CORS issue

See original GitHub issue

Describe the bug

We navigating to a new maps services maps.opensearch.org. Went trying to use it out of the box I keep getting a CORS issue when trying to access a visualization with maps. I had to manually clear my cache then I was able to see maps out of the box. It could potentially be we got some policy cached for the old service and when it attempts to make a call it is making a call with the old policy causing a CORS issue.

To Reproduce Steps to reproduce the behavior:

  1. Have old service working
  2. Create a viz with region maps
  3. Notice map
  4. Use new map service
  5. Create a viz with region maps
  6. Notice CORS issue

Expected behavior Maps works out of the box

OpenSearch Version 1.2

Dashboards Version 1.2

Plugins n/a

Screenshots n/a

Additional context

Need to verify if other folks are seeing this. And will add more content to this issue once I recreate it.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dblockcommented, Nov 18, 2021

@tmarkley @kavilla I understand we changed something in a live configuration. That’s ok as an immediate workaround, but it’s not a fix. I’ll reopen until we confirm that the change made it into code (CDK or otherwise).

1reaction
AMoo-Mikicommented, Nov 17, 2021

Looking at the headers of the failure, we found that CORS headers were missing in the response from the CDN. That is even though the CDN was configured to respond with CORS headers and had been working fine.

One theory is that the failing file, v2.json, was requested in a non-XHR context and a CDN edge cached the response without the CORS headers. Subsequently, a request for the same file, when made via fetch, received the cached response from the CDN which didn’t contain the CORS headers.

Steps to reproduce:

  1. Clear CDN cache
  2. Open https://maps.opensearch.org/tiles/v2.json?osd_version=1.2&opensearch_tos_agree=true in your browser.
    • You should see the response has no CORS headers
  3. Hit that URL with fetch in the console of the browser’s dev-tools:
    fetch("https://maps.opensearch.org/tiles/v2.json?osd_version=1.2&opensearch_tos_agree=true", {
     "referrer": "http://localhost:5602/",
     "referrerPolicy": "strict-origin-when-cross-origin",
     "body": null,
     "method": "GET",
     "mode": "cors",
     "credentials": "omit"
    });
    
    • You should see the response has no CORS headers even if you clear your browser’s cache.

Will continue to look for other explanations with refreshing the CDN cache.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fixing Common Problems with CORS and JavaScript
Tutorial: This post walks through troubleshooting and fixing common problems associated with calling REST APIs from JavaScript.
Read more >
Caching effect on CORS: No 'Access-Control-Allow-Origin ...
First client sends the Origin request header => Cloudfront server caches the response without CORS headers. This made the problem look like it ......
Read more >
CORS errors - HTTP - MDN Web Docs - Mozilla
If the CORS configuration isn't setup correctly, the browser console will present an error like "Cross-Origin Request Blocked: The Same Origin ...
Read more >
CORS Errors: Cross-Origin Resource Sharing - Ionic Framework
CORS errors happen in web apps if requests are made and servers don't return required headers. Read about Cross-Origin Resource Sharing in Ionic ......
Read more >
Cross-origin resource sharing (CORS) | Cloud Storage
XML API endpoints accept CORS requests based on the CORS configuration on the target bucket. The authenticated browser download endpoint storage.cloud.google.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found