Skip to content

Commit bdc1c29

Browse files
committed
Include CORS headers in explicit API error responses
1 parent c874650 commit bdc1c29

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

api/src/errors.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { FetchError, ResponseError } from 'auth0';
66
import { CustomError } from '@httptoolkit/util';
77

88
import log from 'loglevel';
9+
import { getCorsResponseHeaders } from './cors';
910

1011
log.setLevel(process.env.LOGLEVEL as any ?? 'info');
1112

@@ -178,7 +179,10 @@ export function catchErrors(handler: ApiHandler): ApiHandler {
178179
if (specificFailureStatus) {
179180
return {
180181
statusCode: specificFailureStatus,
181-
headers: { 'Cache-Control': 'no-store' },
182+
headers: {
183+
'Cache-Control': 'no-store',
184+
...getCorsResponseHeaders(event)
185+
},
182186
body: e.message
183187
}
184188
} else {

0 commit comments

Comments
 (0)