g00glen00b / dimitri.codes

Static generator for dimitri.codes using Gatsby
https://dimitri.codes
Other
20 stars 8 forks source link

https://dimitri.codes/bundling-react-spring-boot/ #132

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Bundling your React app with Spring boot | Dimitri's tutorials

In this tutorial I'll show you how you can bundle your React app together with Spring boot.

https://dimitri.codes/bundling-react-spring-boot/

pyofori commented 1 year ago

Hello. Nice and informative article. I'm facing a little bit of an issue, I guess because of the spring boot version I'm using. This line 'registry.addViewController("/{x:^(?!api$).*$}/**/{y[\w\-]+}").setViewName("forward:/index.html");)' causes an error:

Error creating bean with name 'viewControllerHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.web.util.pattern.PatternParseException: No more pattern data allowed after {*...} or * pattern element Caused by: org.springframework.web.util.pattern.PatternParseException: No more pattern data allowed after {...} or ** pattern element

g00glen00b commented 1 year ago

@pyofori That's true, this approach no longer works in the newest Spring Boot versions. Nowadays I usually write a custom filter in my backend. For example NotFoundIndexFilter. What this filter does is that each time a webpage is requested that is not containing our API-path, it's returning the index-page. The method I use for detecting if a webpage is requested is by checking if the Accept header contains text/html.

I'm updating the tutorial right now with new information because nowadays I also prefer putting the frontend-resources in its own JAR and including that JAR as a dependency in my backend-project.

pyofori commented 1 year ago

Thanks a lot. This is very helpful.

On Thu, 10 Nov 2022 at 08:12, Dimitri @.***> wrote:

@pyofori https://github.com/pyofori That's true, this approach no longer works in the newest Spring Boot versions. Nowadays I usually write a custom filter in my backend. For example NotFoundIndexFilter https://github.com/g00glen00b/medication-assistant/blob/master/application/src/main/java/be/g00glen00b/apps/mediminder/NotFoundIndexFilter.java. What this filter does is that each time a webpage is requested that is not containing our API-path, it's returning the index-page. The method I use for detecting if a webpage is requested is by checking if the Accept header contains text/html.

I'm updating the tutorial right now with new information because nowadays I also prefer putting the frontend-resources in its own JAR and including that JAR as a dependency in my backend-project.

— Reply to this email directly, view it on GitHub https://github.com/g00glen00b/dimitr.im/issues/132#issuecomment-1309920787, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGB4SKVAEK4ICZYXYUJYPMTWHSU7LANCNFSM6AAAAAAR3SDZ5E . You are receiving this because you were mentioned.Message ID: @.***>