Skip to content

web worker with deploy-url CDN cause SecurityError #14901

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

Closed
vthinkxie opened this issue Jun 26, 2019 · 2 comments · Fixed by #21537
Closed

web worker with deploy-url CDN cause SecurityError #14901

vthinkxie opened this issue Jun 26, 2019 · 2 comments · Fixed by #21537

Comments

@vthinkxie
Copy link

vthinkxie commented Jun 26, 2019

🐞 Bug report

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

no

Description

Angular 8 support build web worker command, but when the app deploys to CDN with --deploy-url, the web worker ts will also loaded from the CDN URL.

This will cause cross domain error

ERROR Error: Uncaught (in promise): SecurityError: Failed to construct 'Worker': 

It makes that impossible to use web worker with @angular/cli in the production environment

Angular CLI should support cross-domain web worker loader with options or by default

async () => {
    const codeString = await fetch(originWorkerUrl).then(res => res.text());
    const localWorkerUrl = window.URL.createObjectURL(new Blob([codeString], {
        type: 'application/javascript'
    }));
}

🔬 Minimal Reproduction

https://angular.io/guide/web-worker
with ng build --prod --deploy-url to any CDN url can easily reproduce this error

🔥 Exception or Error


ERROR Error: Uncaught (in promise): SecurityError: Failed to construct 'Worker': Script at 'http://assets.daily.xxx.net/xxx.worker.js' cannot be accessed from origin 'http://daily.abc.xxx.net'.

Error: Failed to construct 'Worker': Script at 'http://assets.daily.xxx.net/xxx.worker.js' cannot be accessed from origin 'http://daily.abc.xxx.net'.

🌍 Your Environment



     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 8.0.4
Node: 12.4.0
OS: darwin x64
Angular: 8.0.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.4
@angular-devkit/build-angular     0.800.4
@angular-devkit/build-optimizer   0.800.4
@angular-devkit/build-webpack     0.800.4
@angular-devkit/core              8.0.4
@angular-devkit/schematics        8.0.4
@angular/cli                      8.0.4
@ngtools/webpack                  8.0.4
@schematics/angular               8.0.4
@schematics/update                0.800.4
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.30.0
@vthinkxie vthinkxie changed the title web worker with deploy-url CDN will cause web worker with deploy-url CDN will cause SecurityError Jun 26, 2019
@vthinkxie vthinkxie changed the title web worker with deploy-url CDN will cause SecurityError web worker with deploy-url CDN cause SecurityError Jun 26, 2019
@ngbot ngbot bot added this to the Backlog milestone Jun 26, 2019
@arangelp
Copy link

Did someone managed to workaround or solve this issue? I am having the same problem to go to production.

@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 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants