Spring-cloud-netflix: Eureka dashboard static resources not loading when Eureka and Config server get combined (using both @EnableConfigServer and @EnableEurekaServer)

Created on 16 Aug 2016  路  5Comments  路  Source: spring-cloud/spring-cloud-netflix

Hi,
Eureka dashboard is not serving static resources when a class annotated by @EnableEurekaServer is also annotated by @EnableConfigServer.

When only @EnableEurekaServer is present, resources are served correctly.

This seems to be very similar to #1142

The code demonstrating this problem can be found at https://github.com/marmax/eureka-config-server-static-res-issue

question

Most helpful comment

If you really want to embed config server and eureka server together, I suggest you to move your config server path (spring.cloud.config.server.prefix: /config-path) to something different that the eureka.
Otherwise, what you will observe is that when the static resource http://appname:8761/eureka/css/wro.css is fetched, it is routed by the config server as a request for a config properties file (like /application/env).

All 5 comments

I don't think it's a great idea to embed @EnableEurekaServer in a config server for many other reasons. However, if you can find a way to fix this, please send a PR.

Hi @dsyer,
sorry for my ignorance, but can you please name some reasons why to not do so?

I just got inspired by JHipster - a project becoming a popular application prototype - and would like at least to let the guys know about this being not a good practice.

Anyway, I will try to investigate this a bit more.

Thank you in advance,
M.

If you really want to embed config server and eureka server together, I suggest you to move your config server path (spring.cloud.config.server.prefix: /config-path) to something different that the eureka.
Otherwise, what you will observe is that when the static resource http://appname:8761/eureka/css/wro.css is fetched, it is routed by the config server as a request for a config properties file (like /application/env).

@12010994 yes, that's a valid point about those resources being treated by config server.

When I set the prefix as you suggested, the eureka dashboard is served correctly.

Thank you!

I solve with this...

@Configuration
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry
          .addResourceHandler("/eureka/**")
          .addResourceLocations("/eureka/","classpath:/static/eureka/");
    }
}
Was this page helpful?
0 / 5 - 0 ratings