fix: return absolute path as the icon url if CONSOLE_API_URL is empty #15279
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This is follow-up for #15241 by @crazywoola and @zhangxl01.
yarl.URL
The PR #15241 solves the issue by Nginx, but I think the issue should be solved by the API side.
The issue is fundamentally caused by the API returning a relative path (without leading
/
) as the icon URL when theCONSOLE_API_URL
is empty.If the specified URL does not start with
/
, the browser treats it as a relative path from the current URL. This causes 404 for all icons (See the screen shot below).Simply ensuring that the API returns a path starting with
/
as the icon URL will resolve the issue, as the browser will interpret it as an absolute path from the root of the current domain.Related #15189, #14668, #14835, #14570, #13982, #14835, #14578
Screenshots
Checklist
Important
Please review the checklist below before submitting your pull request.
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint gods