Static Files Not Serving on Replit
CSS, JavaScript, and images return 404 or don't load on deployed Replit app. Static resources are missing or misconfigured.
Spring Boot has specific requirements for static file locations and configuration.
Error Messages You Might See
Common Causes
- Static files not in correct directory (should be src/main/resources/static)
- Spring static resource mapping not configured
- Build process excludes static files from JAR
- Incorrect static resource prefix in HTML templates
- GZIP compression causing browser caching issues
How to Fix It
Place files in src/main/resources/static/css, src/main/resources/static/js. Use Thymeleaf th:href=@{/path/to/file.css} for template links. Ensure build.gradle includes static resources. Disable static resource caching in development with spring.web.resources.cache.period=0. Check Content-Type headers are correct.
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
Where do static files go?
src/main/resources/static/ - Spring Boot serves these automatically at /