@@ -10,6 +10,7 @@ import type { AngularServerApp, getOrCreateAngularServerApp } from './app';
1010import { Hooks } from './hooks' ;
1111import { getPotentialLocaleIdFromUrl , getPreferredLocale } from './i18n' ;
1212import { EntryPointExports , getAngularAppEngineManifest } from './manifest' ;
13+ import { createRedirectResponse } from './utils/redirect' ;
1314import { joinUrlParts } from './utils/url' ;
1415import { cloneRequestAndPatchHeaders , validateRequest } from './utils/validation' ;
1516
@@ -146,7 +147,7 @@ export class AngularAppEngine {
146147
147148 if ( this . supportedLocales . length > 1 ) {
148149 // Redirect to the preferred language if i18n is enabled.
149- return this . redirectBasedOnAcceptLanguage ( request ) ;
150+ return this . redirectBasedOnAcceptLanguage ( securedRequest ) ;
150151 }
151152
152153 return null ;
@@ -179,13 +180,14 @@ export class AngularAppEngine {
179180 if ( preferredLocale ) {
180181 const subPath = supportedLocales [ preferredLocale ] ;
181182 if ( subPath !== undefined ) {
182- return new Response ( null , {
183- status : 302 , // Use a 302 redirect as language preference may change.
184- headers : {
185- 'Location' : joinUrlParts ( pathname , subPath ) ,
186- 'Vary' : 'Accept-Language' ,
187- } ,
188- } ) ;
183+ const prefix = request . headers . get ( 'X-Forwarded-Prefix' ) ?? '' ;
184+
185+ return createRedirectResponse (
186+ joinUrlParts ( prefix , pathname , subPath ) ,
187+ 302 ,
188+ // Use a 302 redirect as language preference may change.
189+ { 'Vary' : 'Accept-Language' } ,
190+ ) ;
189191 }
190192 }
191193
0 commit comments