create-react-app 提供一些能力,在需要时为JS块脚本标签设置跨域属性,

63lcw9qa  于 6个月前  发布在  React
关注(0)|答案(1)|浏览(69)

I am using CRA for a website, which serve its script via CDN, by set PUBLIC_URL to CDN host , everthing works fine . But soon I realized its imposiible for sentry-like tools to get Error detail for the crossOrigin attribute is not 'annoymous' in script tag.

Describe the solution you'd like

Just like what we do with PUBLIC_URL , maybe it is convient to provide a ENV key like 'SCRIPT_ACCROSS_ORIGIN' ?
Or maybe more convinent is to detect whether the PUBLIC_URL is an absolute path , and if does ,automatically generate scipt tag with acrossorigin="annoymous" ?

Describe alternatives you've considered

I have to turn my project into a react-app-rewired or craco version to modify webpack config to achieve my goal;
Or write some ugly script to parse and modify my generated index.html after build;

Additional context

kcrjzv8t

kcrjzv8t1#

有一个same issue,但很快就关闭了,没有解决方案。

相关问题