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

Not allowed to load local resource -> ModuleBuildError: Module build failed -> TypeError: Failed to fetch dynamically imported module #1478

Open
1 task done
jantimon opened this issue Jun 30, 2024 · 1 comment
Labels

Comments

@jantimon
Copy link

jantimon commented Jun 30, 2024

Describe the bug

When using next-yak 0.2.1 on StackBlitz, the compilation fails due to a security error preventing the loading of a local resource.

Chrome/Brave:

Not allowed to load local resource: file:///home/projects/stackblitz-starters-bp97wq/node_modules/next-yak/dist/loaders/tsloader.js

Firefox:

Security error: Content on https://stackblitzstartersbp97wq-hlff.w-corp-staticblitz.com/iframe.70dbe416.html is not allowed to load or link file:///home/projects/stackblitz-starters-bp97wq/node_modules/next-yak/dist/loaders/tsloader.js

Safari:

[Error] Cannot load file:///home/projects/stackblitz-starters-bp97wq/node_modules/next-yak/dist/loaders/tsloader.js due to access control checks.
[Error] Failed to load resource: Cross origin requests are only supported for HTTP. (tsloader.js, line 0)

The problem arises because next-yak integrates into the Next.js config and injects a webpack loader using an absolute path (e.g., /home/projects/stackblitz-starters-bp97wq/node_modules/next-yak/dist/loaders/tsloader.js).

As soon as Next.js triggers the compilation and attempts to execute the loader, it fails due to the security restrictions in StackBlitz's environment

Link to the blitz that caused the error

https://stackblitz.com/edit/stackblitz-starters-bp97wq

Steps to reproduce

  1. Open this StackBlitz project: https://stackblitz.com/edit/stackblitz-starters-bp97wq
  2. The error occurs immediately on initial page load as the compilation is triggered.

Expected behavior

The project should compile and run successfully, as it does in a local environment

Parity with Local

Screenshots

Error in Stackblitz

Platform

Browser name  = Chrome
Full version  = 126.0.0.0
Major version = 126
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
performance.memory = {
  "totalJSHeapSize": 273394398,
  "usedJSHeapSize": 226013986,
  "jsHeapSizeLimit": 4294705152
}
Hash = 70dbe416

Additional context

Worked before with next-yak 0.2.0:
https://stackblitz.com/edit/stackblitz-starters-dfykqy?file=app%2Fpage.tsx

@SamVerschueren
Copy link
Contributor

Hey @jantimon 👋 ! Thanks for reaching out. This looks like a bug indeed. I'll create a ticket and see what's causing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants