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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans