@@ -20,14 +20,17 @@ import {
2020import { ApiService , AppConfiguration , AuthToken } from '@hazmapper/types' ;
2121import { HASHED_SESSION } from '@hazmapper/utils/requestUtils' ;
2222
23- export const getApiClient = ( apiService : ApiService = ApiService . Geoapi ) => {
23+ export const getApiClient = (
24+ apiService : ApiService = ApiService . Geoapi ,
25+ geoapiEnv : string
26+ ) => {
2427 const axiosConfig = {
2528 timeout : 60 * 1000 , // 1 minute
2629 } ;
2730 if ( apiService === ApiService . Geoapi ) {
2831 Object . assign ( axiosConfig , {
29- xsrfCookieName : ' csrftoken' ,
30- xsrfHeaderName : ' x-csrftoken' ,
32+ xsrfCookieName : ` csrftoken- ${ geoapiEnv } ` ,
33+ xsrfHeaderName : ` x-csrftoken- ${ geoapiEnv } ` ,
3134 withCredentials : true , // Ensure cookies are sent with requests
3235 withXSRFToken : true ,
3336 } ) ;
@@ -135,8 +138,8 @@ export function useGet<ResponseType, TransformedResponseType = ResponseType>({
135138 transform,
136139 prefetch,
137140} : UseGetParams < ResponseType , TransformedResponseType > ) {
138- const client = getApiClient ( apiService ) ;
139141 const configuration = useAppConfiguration ( ) ;
142+ const client = getApiClient ( apiService , configuration . geoapiEnv ) ;
140143 const { accessToken : mapillaryAuthToken } = useMapillaryToken ( ) ;
141144
142145 const isPublicRoute = useIsPublicProjectRoute ( ) ;
@@ -186,8 +189,8 @@ export function usePost<RequestType, ResponseType>({
186189 options = { } ,
187190 apiService = ApiService . Geoapi ,
188191} : UsePostParams < RequestType , ResponseType > ) {
189- const client = getApiClient ( apiService ) ;
190192 const configuration = useAppConfiguration ( ) ;
193+ const client = getApiClient ( apiService , configuration . geoapiEnv ) ;
191194
192195 const baseUrl = getBaseApiUrl ( apiService , configuration ) ;
193196
@@ -239,8 +242,8 @@ export function useDelete<ResponseType, Variables>({
239242 options = { } ,
240243 apiService = ApiService . Geoapi ,
241244} : UseDeleteParams < ResponseType , Variables > ) {
242- const client = getApiClient ( apiService ) ;
243245 const configuration = useAppConfiguration ( ) ;
246+ const client = getApiClient ( apiService , configuration . geoapiEnv ) ;
244247
245248 const baseUrl = getBaseApiUrl ( apiService , configuration ) ;
246249 const isTapisTokenRequest = usesTapisToken ( apiService ) ;
@@ -282,8 +285,8 @@ export function usePut<RequestType, ResponseType>({
282285 options = { } ,
283286 apiService = ApiService . Geoapi ,
284287} : UsePostParams < RequestType , ResponseType > ) {
285- const client = getApiClient ( apiService ) ;
286288 const configuration = useAppConfiguration ( ) ;
289+ const client = getApiClient ( apiService , configuration . geoapiEnv ) ;
287290
288291 const baseUrl = getBaseApiUrl ( apiService , configuration ) ;
289292
0 commit comments