66} from '../../i18n/utils.js' ;
77import type { MiddlewareHandler , Params , RewritePayload } from '../../types/public/common.js' ;
88import type { APIContext , AstroSharedContextCsp } from '../../types/public/context.js' ;
9- import { ASTRO_VERSION , clientLocalsSymbol } from '../constants.js' ;
9+ import { ASTRO_VERSION } from '../constants.js' ;
1010import { AstroCookies } from '../cookies/index.js' ;
1111import { AstroError , AstroErrorData } from '../errors/index.js' ;
1212import { getClientIpAddress } from '../routing/request.js' ;
@@ -43,7 +43,7 @@ export type CreateContext = {
4343 /**
4444 * Initial value of the locals
4545 */
46- locals : App . Locals ;
46+ locals ? : App . Locals ;
4747} ;
4848
4949/**
@@ -54,7 +54,7 @@ function createContext({
5454 params = { } ,
5555 userDefinedLocales = [ ] ,
5656 defaultLocale = '' ,
57- locals,
57+ locals = { } ,
5858} : CreateContext ) : APIContext {
5959 let preferredLocale : string | undefined = undefined ;
6060 let preferredLocaleList : string [ ] | undefined = undefined ;
@@ -110,15 +110,10 @@ function createContext({
110110 return clientIpAddress ;
111111 } ,
112112 get locals ( ) {
113- // TODO: deprecate this usage. This is used only by the edge middleware for now, so its usage should be basically none.
114- let _locals = locals ?? Reflect . get ( request , clientLocalsSymbol ) ;
115- if ( locals === undefined ) {
116- _locals = { } ;
117- }
118- if ( typeof _locals !== 'object' ) {
113+ if ( typeof locals !== 'object' ) {
119114 throw new AstroError ( AstroErrorData . LocalsNotAnObject ) ;
120115 }
121- return _locals ;
116+ return locals ;
122117 } ,
123118 set locals ( _ ) {
124119 throw new AstroError ( AstroErrorData . LocalsReassigned ) ;
0 commit comments