I have a web service running in springboot on port 8080. when I hit below url it works fine:
http://localhost:8080/app , i redirect the url to below:
http://localhost:8080/myHome/home
now when i refresh the page I am getting 404
below is the content of my index.html:
<base href="/myHome">
package.json:
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build --dev --deploy-url=\"/app/\"",
"test": "ng test",
"lint": "ng lint",
"e2e": "protractor"
},
I had tried using LocationStrategy mentioned in
Angular 2: 404 error occur when I refresh through the browser , but its not working for me.
I had the same problem in spring boot 2. I have added resources resolver location as static directory and if not matched with any file then load index.html
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**/*")
.addResourceLocations("classpath:/static/")
.resourceChain(true)
.addResolver(new PathResourceResolver() {
@Override
protected Resource getResource(String resourcePath, Resource location) throws IOException {
Resource requestedResource = location.createRelative(resourcePath);
return requestedResource.exists() && requestedResource.isReadable() ? requestedResource : new ClassPathResource("/static/index.html");
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With