Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CORS error for self hosted files?

(0) ShareShare
ReportReport
Posted on by 225

I've created a couple of webresources:

- app.html
- app.js

- schedule.module.js (ES6)

In app.js, the very first line is import { 'Schedule' } from 'schedule.module.js', I get this error:

Access to script at 'login.microsoftonline.com/.../authorize...' (redirected from 'demo.crm4.dynamics.com/.../hef_app.js') from origin 'https://demo.crm4.dynamics.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I'm really unsure on how to link schedule.module.js. Do I simply use its name, or full path as you get them when you create the webresource (I tried both doh)? Is there limitation in Dynamics on this, as long as my browser supports ES6 then it should be all good?

*This post is locked for comments

  • Suggested answer
    gdas Profile Picture
    gdas 50,089 on at
    RE: CORS error for self hosted files?

    Hi,

    Try to write <script type="text/javascript" src=...   instead of <script type="module"  .

  • _Lars_ Profile Picture
    _Lars_ 225 on at
    RE: CORS error for self hosted files?

    I am NOT trying to include a script file from another domain. The scriptfile is uploaded as a webresource.

    ---

    Further more I got this errormessage while trying to fix the problem:

    Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

    In app.html I include the app.js as

    <script type="module" src="demo.crm4.dynamics.com/.../hef_app.js">

    app.js on the first line does a import {} from 'schedule.module.js'. CORS crash and everything is sad.

    But If I go back to the inclusion of the hef_app.js and change the type to "text/javascript" I get the error above. Is module support limited?

  • Suggested answer
    gdas Profile Picture
    gdas 50,089 on at
    RE: CORS error for self hosted files?

    Hi ,

    Please check below old thread might be useful for you-

    community.dynamics.com/.../805676

    https://community.dynamics.com/crm/f/117/t/273154

    In addition add the target domain as a trusted site in the browser.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,401 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans