admin管理员组文章数量:1304137
I am using Angular 16 and the production dist generated by Angular imports the styles.css in a relative fashion as below:
<link ref="stylesheet" href="styles-CXBDUENS.css" />
This has been flagged as a vulnerability (PRSSI) by our security team as per the Qualys scan. Refer the vulnerability here -
The expected import should be:
<link ref="stylesheet" href="/styles-CXBDUENS.css" />
with a leading slash at the start, which makes the import static from the root folder.
Is there any way to tell Angular to import it in the correct way.
Since, the build is generated via a CICD pipeline, the only workaround that I have currently is to modify the generated index.html file manually. Is there any better way to do this ?
I am using Angular 16 and the production dist generated by Angular imports the styles.css in a relative fashion as below:
<link ref="stylesheet" href="styles-CXBDUENS.css" />
This has been flagged as a vulnerability (PRSSI) by our security team as per the Qualys scan. Refer the vulnerability here - https://portswigger/kb/issues/00200328_path-relative-style-sheet-import
The expected import should be:
<link ref="stylesheet" href="/styles-CXBDUENS.css" />
with a leading slash at the start, which makes the import static from the root folder.
Is there any way to tell Angular to import it in the correct way.
Since, the build is generated via a CICD pipeline, the only workaround that I have currently is to modify the generated index.html file manually. Is there any better way to do this ?
Share Improve this question edited Feb 4 at 19:42 JSON Derulo 17.8k11 gold badges57 silver badges75 bronze badges asked Feb 4 at 16:00 Saurabh TiwariSaurabh Tiwari 5,16111 gold badges50 silver badges90 bronze badges1 Answer
Reset to default 0You can use the --deploy-url
option when running the ng build
comand:
ng build --deploy-url=/
Alternatively, you can set the deployUrl
build option in your angular.json
to keep the CLI commands clean, but it does the same thing.
本文标签: securityAngular generating indexhtml file with relative css file importsStack Overflow
版权声明:本文标题:security - Angular generating index.html file with relative css file imports - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741754603a2396037.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论