fix: proxy OAuth2/login/logout paths through nginx to Spring BFF

nginx was only forwarding /api/* to the backend.
Added proxy locations for:
  - /oauth2/  (Spring Security login initiation)
  - /login/oauth2/  (OAuth2 authorization code callback)
  - /logout  (Spring Security logout + RP-initiated end-session)

Also revert incorrect /api prefix on the login redirect URL.
This commit is contained in:
nessar committed 2026-08-17 14:18:14 +02:00
1 parent be80422c99
commit 92d16eb2c1
2 files changed
+28 -1

No files matched your search

+27
View File
@@ -16,6 +16,33 @@ server {
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
} }
# Spring Security OAuth2 login initiation
location /oauth2/ {
proxy_pass http://backend:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Spring Security OAuth2 callback (authorization code)
location /login/oauth2/ {
proxy_pass http://backend:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Spring Security logout endpoint
location /logout {
proxy_pass http://backend:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
error_page 500 502 503 504 /50x.html; error_page 500 502 503 504 /50x.html;
location = /50x.html { location = /50x.html {
root /usr/share/nginx/html; root /usr/share/nginx/html;
+1 -1
View File
@@ -42,7 +42,7 @@ export class App implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.http.get<{authenticated: boolean, username?: string, email?: string}>('/api/user').subscribe({ this.http.get<{ authenticated: boolean, username?: string, email?: string }>('/api/user').subscribe({
next: (user) => { next: (user) => {
if (user.authenticated) { if (user.authenticated) {
this._isLoggedIn.set(true); this._isLoggedIn.set(true);