Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for crossorigin in differential loading #14743

Closed
BernhardRode opened this issue Jun 12, 2019 · 1 comment · Fixed by #14844
Closed

feat: Add support for crossorigin in differential loading #14743

BernhardRode opened this issue Jun 12, 2019 · 1 comment · Fixed by #14844
Assignees
Labels
area: @angular-devkit/build-angular feature Issue that requests a new feature
Milestone

Comments

@BernhardRode
Copy link

We are using a transparent authentication gateway from Azure (https://docs.microsoft.com/de-de/azure/app-service/overview-authentication-authorization) in front of our applications. It captures all requests and some 'new' tags like:

  • <script type="module" src="…">

need the attribute crossorigin="use-credentials" to be working, as the
It also seems, that Safari is a little bit stricter here, then chrome. Chrome just needs the attribute for the manifest, Safari for both.

If crossorigin is not provided, the browsers throw errors like:

https://login.microsoftonline.com/XXXXX/oauth2/authorize?response_type=code+id_token&redirect_uri=https%3A%2F%2Fapp.azurewebsites.net%2F.auth%2Flogin%2Faad%2Fcallback&client_id=XXXXX&scope=openid+profile+email&response_mode=form_post&resource=https%3A%2F%2Fgraph.windows.net&nonce=XXXXX&state=redir%3D%252Fmain-es2015.3959c9c93c3c451fefc1.js
denied by Cross-Origin Resource Sharing policy: Origin
https://app.azurewebsites.net is not allowed by Access-Control-Allow-Origin.

Some infos about the attribute:
https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes

We already did some tests:

  • First we changed "target": "es2015" to "target": "es5" in tsconfig.json
    -> the application works

  • Then we moved back to es2015 and added a npm build step to our pipeline (thanks to @manfredsteyer)

"build:prod": "ng build --prod && npm run build:replace",
"build:replace": "sed -i.bak 's/type=\"module\"/type=\"module\" crossorigin=\"use-credentials\"/g' dist/app/index.html",

-> the application works

Both workarounds are fine for us, but I think others would like to have an option to configure crossorigin for modules.

🚀 Feature request

Command (mark with an x)

- [X] build

Description

Add a compiler option:

  • p.E. moduleCrossorigin - off | '' | anonymous | use-credentials

Describe the solution you'd like

Generated script tags in index.html should get an additional attribute if the new compilerOption is set:

If moduleCrossorigin is not set: <script type="module" src="…">
If moduleCrossorigin is '' or anonymous: <script type="module" crossorigin="anonymous" src="…">
If moduleCrossorigin is use-credentials: <script type="module" crossorigin="use-credentials" src="…">

Describe alternatives you've considered

Described manual replacements via npm scripts above.

@alan-agius4 alan-agius4 added area: @angular-devkit/build-angular feature Issue that requests a new feature labels Jun 12, 2019
@ngbot ngbot bot modified the milestone: Backlog Jun 12, 2019
@alan-agius4 alan-agius4 modified the milestones: Backlog, 8.1.0 Jun 13, 2019
@alan-agius4 alan-agius4 self-assigned this Jun 20, 2019
vikerman pushed a commit that referenced this issue Jun 27, 2019
This options allows to define the crossorigin attribute setting of elements that provide CORS support

Closes #14743
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @angular-devkit/build-angular feature Issue that requests a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants