web
You’re offline. This is a read only version of the page.
close
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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans