I’m using a Spring OAuth2 Authorization Server with a Gateway in front of it.
When I access the login page directly via http://localhost:9999 (the OAuth2 server port), everything works: the CSS loads correctly, and I can sign in without issues.
But when I go through the Gateway, the login page loads without CSS, and submitting valid credentials just reloads the page instead of signing me in.
The Authorization Server itself works fine: I can acquire access tokens and authorization codes through the Gateway without problems. The issue only happens with the login page.
What configuration am I missing in the Gateway to make the OAuth2 login page work properly?
server.ssl.bundle: gateway
spring:
application:
name: gateway
ssl.bundle.jks.gateway:
key:
alias: name
keystore:
type: PKCS12
location: classpath:keystore/name-keystore.p12
password: secret
cloud:
gateway:
server:
webmvc:
trusted-proxies: ".*"
routes:
- id: certificate
uri: lb://certificate
predicates:
- Path=/certificate/**
- id: company
uri: lb://company
predicates:
- Path=/company/**
- id: review
uri: lb://review
predicates:
- Path=/review/**
##actuator
- id: review-actuator
uri: lb://review
predicates:
- Path=/review/actuator/**
filters:
- RewritePath=/review/(?<segment>.*), /$\{segment}
##eureka
- id: eureka-api
uri: http://${app.eureka-server}:8761
predicates:
- Path=/eureka/api/{segment}
filters:
- SetPath=/eureka/{segment}
- id: eureka-web-start
uri: http://${app.eureka-server}:8761
predicates:
- Path=/eureka/web
filters:
- SetPath=/
- id: eureka-web-other
uri: http://${app.eureka-server}:8761
predicates:
- Path=/eureka/**
## authorization-server
- id: oauth2-server
uri: lb://authorization-server
predicates:
- Path=/oauth2/**
- id: oauth2-login
uri: lb://authorization-server
predicates:
- Path=/login/**
- id: oauth2-error
uri: lb://authorization-server
predicates:
- Path=/error/**
- id: oauth2-static-resources
uri: lb://authorization-server
predicates:
- Path=/css/**, /js/**, /images/**
##config ONLY FOR DEV
- id: config-server
uri: ${spring.cloud.config.uri}
predicates:
- Path=/config/**
filters:
- RewritePath=/config/(?<segment>.*), /$\{segment}
server:
port: 8443
spring.security.oauth2.resourceserver.jwt.issuer-uri: "http://${app.auth-server}:9999" ```
-
Did you route your static resources to the Auth server ?user17466897– user174668972025年09月06日 15:16:11 +00:00Commented Sep 6, 2025 at 15:16
-
The login page is the default you mean this right? ` - id: oauth2-static-resources uri: lb://auth-server predicates: - Path=/css/**, /js/**, /images/** `Mast Reyheart– Mast Reyheart2025年09月06日 15:18:40 +00:00Commented Sep 6, 2025 at 15:18
-
Yes but I think The default login page uses: /login (GET + POST), /logout, /error, /webjars/** (for Js/Css dependencies) /favicon.ico and possibly /oauth2/** endpoints ?user17466897– user174668972025年09月06日 16:36:03 +00:00Commented Sep 6, 2025 at 16:36
-
for the login i only do a GET to the 9999 and it works correctly i am using the browser not a curl or postman to access itMast Reyheart– Mast Reyheart2025年09月07日 13:22:34 +00:00Commented Sep 7, 2025 at 13:22