Relative urls when generating static report
BirknerAlex opened this issue · 2 comments
Describe the bug
I am using --build-static
to generate the HTML report in our pipeline. Since I will use Gitlab Pages for the reports and having only one page domain for all branches I move the reports to a relative path.
As example when having the Pages URL https://project.pages.domain.com
, will move the reports to https://project.pages.domain.com/<branch>/
. This does not work since all asset urls are using absolute paths in the generated index.html, css and js files.
I am currently replacing them with sed -i 's/\/assets\//assets\//g' public/$UNLIGHTHOUSE_REPORT_PATH/index.html
.
This works for the most but some assets are still requested from the absolute URL which results in an 404 response from the webserver.
Example:
# URL in rendered HTML
https://project.pages.domain.com/reports/en/news/screenshot.jpeg
# Real URL:
https://project.pages.domain.com/<branch>reports/en/news/screenshot.jpeg
Reproduction
No response
System / Nuxt Info
No response
👋 you’re looking for the routerPrefix
/ --router-prefix
option I believe. See #11.
Thanks, @thibaudcolas, this is the right solution so I'll close this.