Spring Boot Map Static Files (React)

Asked

Viewed 61 times

-1

My question is, how do I map static files, for example in Nodejs using Express, I can:

app.get('*', (req, res) => {
  res.sendFile(path.resolve(__dirname, '../build', 'index.html'));
});

So all requests I send to index.html, have anything equivalent in Spring Boot? The reason I want this is to run React in the production environment inside the spring web server, if what I’m thinking of doing is wrong/gambiarra there’s another way?

1 answer

0


Good Morning,

Loveliness?

Man, there is but I found it kind of strange how you want to use it there.

Anyway, on their website (Spring) there is a basic tutorial to do what you want, I think it can help you.

Follow the link: https://spring.io/guides/gs/serving-web-content/

Hug.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.