Issue with :base-url that has a context path
Closed this issue · 0 comments
When you're serving assets from a CDN, you can add a :base-url
to each asset. This URL will be added to links to the assets. Like this:
{:path "/scripts/code.js"
:base-url "http://cdn.example.com"}
When you call (optimus.link/file-path request "/scripts/code.js")
you get http://cdn.example.com/scripts/code.js
.
The problem arises in CSS files. They too link to assets, but unless you explicitly update their :contents
, they won't use the :base-url
. This isn't a problem in the example above. Since they're using absolute URLs, they'll use the base URL as long as they're served from there.
However, if the base URL contains a context path: http://cdn.example.com/mysite
- then the absolute paths in CSS fail.
In that case, we either need to update the contents of all CSS files with the base URL. Or we could use relative paths instead.