I am creating a system based on the micro services architecture with the following flow.
eureka porta (8888)
zuul porta (8080)
stu_user (8081) / User / **
stu_veiculo (8082) / Vehicle / **
As I understand zuul is a gateway where when asked for example localhost:8080/Usuario/listar
it will go into service stu_usuario
and it will return the desired page until then, but when I started to use some .js
and .css
this request can not load because it tries to load the files on host 8080 but they only exist in 8081.
application.properties
spring.application.name=zuul
zuul.add-host-header=true
server.tomcat.remote-ip-header=x-forwarded-host
# configurações do serviço usuario
zuul.routes.stu_usuario.path=/Usuario/**
zuul.routes.stu_usuario.url=http://localhost:8081
zuul.routes.stu_usuario.serviceId=stu_usuario
zuul.routes.stu_usuario.stripPrefix=false
zuul.routes.stu_usuario.sensitive-headers=Cookie,Set-Cookie,Authorization
# configurações do serviço veiculo
zuul.routes.stu_veiculo.path=/Veiculo/**
zuul.routes.stu_veiculo.url=http://localhost:8082
zuul.routes.stu_veiculo.serviceId=stu_veiculo
zuul.routes.stu_veiculo.stripPrefix=false
zuul.routes.stu_veiculo.sensitive-headers=Cookie,Set-Cookie,Authorization
eureka.client.serviceUrl.defaultZone=http://localhost:8888/eureka
eureka.client.register-with-eureka=true
server.port=8080
springbootapplication
@SpringBootApplication
@EnableDiscoveryClient
@EnableZuulProxy
public class Configuracao {
public static void main(String[] args) {
SpringApplication.run(Configuracao.class, args);
}
@Bean
public PreFilter preFilter() {
return new PreFilter();
}
@Bean
public PostFilter postFilter() {
return new PostFilter();
}
@Bean
public ErrorFilter errorFilter() {
return new ErrorFilter();
}
@Bean
public RouteFilter routeFilter() {
return new RouteFilter();
}
}