0

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" ```
asked Sep 6, 2025 at 15:10
4
  • Did you route your static resources to the Auth server ? Commented 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/** ` Commented 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 ? Commented 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 it Commented Sep 7, 2025 at 13:22

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.