1

We're trying to serve a React app via Spring Boot.

Spring is able to serve the CSS folder's css files (src/main/resources/static/css/), but is not able to serve the JS folder's files (src/main/resources/static/js/). There is a main.8f965741.chunk.js inside the JS folder, and when we run the application, it is returning an error 404.

It is not a browser/caching issue. It is not a folder/file permissions issue.

Any thoughts on how to debug this? Spring gives us essentially no output for the 404.

1 Answer 1

2

You can turn on DEBUG (or TRACE) level logs by adding the following to your application.properties:

logging.level.org.springframework.web: TRACE

Then try requesting the JS file directly, perhaps with curl (e.g., curl http://localhost:8080/js/main.8f965741.chunk.js)

The logs should tell you how the request was mapped and how it was subsequently handled. You can compare the logs generated here with a "known good" request (perhaps from requesting a css file).

If you've built a .jar or .war artifact, you can also unpack it (using jar xf ...) and double check if the js files are properly packaged there.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the advice! We're pretty new to Spring and this helped us figure it out. We were serving from src/main/resources but the problem went away when we build a .jar so we're going with that for now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.