Skip to content

Commit 5e0c1c2

Browse files
committed
Change detection of fetch event
1 parent fe40f61 commit 5e0c1c2

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

packages/api/src/transforms.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Headers, Request as PonyFillRequest } from '@whatwg-node/fetch'
1+
import { Headers } from '@whatwg-node/fetch'
22
import type { APIGatewayProxyEvent } from 'aws-lambda'
33

44
// This is part of the request, dreived either from a LambdaEvent or FetchAPI Request
@@ -50,14 +50,13 @@ export const parseFetchEventBody = async (event: Request) => {
5050
export const isFetchApiRequest = (
5151
event: Request | APIGatewayProxyEvent
5252
): event is Request => {
53-
if (
54-
event.constructor.name === 'Request' ||
55-
event.constructor.name === PonyFillRequest.name
56-
) {
57-
return true
53+
// Arda has suggested it's better to check for a lambda event than a fetch event
54+
// as there are some edgecases with constructor name in PonyfillRequest
55+
if ('httpMethod' in event || 'resource' in event) {
56+
return false
5857
}
5958

60-
return false
59+
return true
6160
}
6261

6362
function getQueryStringParams(reqUrl: string) {

0 commit comments

Comments
 (0)