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

【@vitejs/plugin-legacy】type="module" 对于file协议引入资源会有跨域问题 #12841

Closed
4 tasks done
kidjayhuang opened this issue Apr 13, 2023 · 2 comments · Fixed by #8524
Closed
4 tasks done

Comments

@kidjayhuang
Copy link

Description

某些场景,例如 app 本地h5包,会直接用file协议打开html入口。然后安卓低端机,目前测试结果是 android <=11,会因为跨域问题加载不出脚本,也不会被@vitejs/plugin-legacy 捕捉错误去加载 legacy脚本。建议是加上 type="module"导致的跨域判断[doge]

Suggested solution

我自己fork下来,将__vite_is_modern_browser暂时写死为false,
const detectModernBrowserCode = ${detectModernBrowserDetector}window.${detectModernBrowserVarName}=false;`
建议跟判断是否支持esm一样,判断跨域错误的场景才去加载 legacy 咯

Alternative

No response

Additional context

No response

Validations

@bluwy
Copy link
Member

bluwy commented Apr 13, 2023

If you mean that you're trying to use plugin-legacy with the file protocol, there's a PR to support it: #2574, but it's quite outdated.

@ZHUIMEN
Copy link

ZHUIMEN commented Apr 17, 2023

How to solve this problem in the end also bothers me.

@github-actions github-actions bot locked and limited conversation to collaborators May 10, 2023
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