Select to view content in your preferred language

Observing CORS error while using JS API 4.27 in a custom React application

2466
10
06-22-2023 08:52 PM
LAProAg
Emerging Contributor

We are experiencing CORS error when application is deployed. No errors while accessing through localhost:

Access to fetch at 'https://js.arcgis.com/4.27/@arcgis/core/assets/esri/widgets/Zoom/t9n/Zoom_en.json' from origin '<our application>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

After doing some research it seems we have to use 

import Config from "@arcgis/core/config"; module and add 

  Config.request.trustedServers?.push("[https://js.arcgis.com/]");
 
but when I do that I get these errors:

Logger.js:5 [esri.widgets.Attribution] widget-intl:locale-error esri.widgets.Attribution

  1. {name: 'intl:message-bundle-error', details: {…}, message: 'Errors occurred while loading "esri/widgets/Attribution/t9n/Attribution"'}
    1. details: {errors: Array(1)}
    2. message: "Errors occurred while loading \"esri/widgets/Attribution/t9n/Attribution\""
    3. name: "intl:message-bundle-error"
    4. [[Prototype]]: e

Has anyone experience any issues like this. Would really appreciate any help in this

Thanks

-Luv

Tags (2)
10 Replies
Lerman
by
Frequent Contributor

Great, glad to hear that!@LAProAg

0 Kudos