404 errors on font files imported by scss files
Current Behavior
Often scss files import font files in some font directory. These can be done using relative paths. However these paths are resolved against DOTSASS resulting in a path like:
http://localhost/DOTSASS/application/themes/quest/fonts/glyphicons-halflings-regular.ttf
This results in a 404 error.
Expected Behavior
I expect this to resolve normally or at least do a redirect to the same path without "DOTSASS":
http://localhost/application/themes/quest/fonts/glyphicons-halflings-regular.ttf
Possible Solution
This can be easily solved by adding redirect functionality in the CSSPreProcessServlet. Here is example:
String reqURI=req.getRequestURI\(\);
String uri = reqURI.substring\(reqURI.indexOf\('/', 1\)\);
String fileName = reqURI.substring\(reqURI.lastIndexOf\('/'\)\);
if\(fileName.contains\("?"\)\) {
// remove potential parameters
fileName = reqURI.substring\(0, fileName.lastIndexOf\('?'\)\);
}
if \(fileName.endsWith\(".eot"\) || fileName.endsWith\(".svg"\) || fileName.endsWith\(".ttf"\)|| fileName.endsWith\(".woff"\)\) {
resp.setStatus\(HttpServletResponse.SC*MOVED*PERMANENTLY\);
resp.setHeader\("Location", uri\);
return;
}
Known Workarounds
Change scss files that import fonts to use absolute paths instead of relative paths. However this step should not be necessary and is a pain when importing existing themes.
Your Environment
- dotCMS version used: 4.3.3
- Operating System and version: Windows 10 Pro, Version 1803
- Java Brand and version: "1.8.0_172"
This issue has been automatically marked as stale because it has not had activity within the past 90 days. It will be closed in 30 days no further activity occurs. Thank you.