web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    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.

  • _Lars_ Profile Picture
    225 on at

    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
    50,091 Moderator on at

    Hi,

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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans