Replies: 2 comments
-
|
second try in discussion #14514 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Hi! Spring Boot integration with Vite requires some specific configuration. Here's how to fix your issues: 1. Base URL ConfigurationIn export default {
base: process.env.NODE_ENV === 'production' ? '/your-app/' : '/',
server: {
port: 3000,
}
}In your Vue Router: const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [...]
})
export default {
server: {
proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
}
}
}
}This should preserve HMR while proxying backend requests.
Make sure your controller handles SPA routing in production: @Controller
public class ForwardController {
@GetMapping(value = "/{path:[^\\.]*}")
public String forward() {
return "forward:/";
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I successfully integrated Vue frontends in several Spring Boot projects using webpack based builds. Now I would like to switch to Vite + Vue. Everything seems to run perfectly fine with production builds but I experience some problems when using Vites dev server. Some of them may have to do with the fact that I provide different
baseUrls for the build process and for the Vue Router - e.g. doing a browser reload produces the messagein the browser. Moreover I fail to configure the proxy of the dev server such that live reload still works and the communication to the Spring Boot backend works.
All things that worked with webpack's dev server for years without any problems. Of course the problem must be me, so any help is appreciated. ;-)
Since all this stuff is not easy to explain I created a github repo with a very simple Spring Boot demo project containing two frontends - one build with vue-cli, the other one with vite.
As I said in a question on SO which I also created: Comments, help and PRs are welcome!
Beta Was this translation helpful? Give feedback.
All reactions