tessellator / sveltekit-adapter-lambda

Adapter for SvelteKit applications that generates a handler for use on AWS Lambda
MIT License
13 stars 0 forks source link

TypeError: Cannot read properties of undefined (reading 'pathname') #3

Closed wwwesleyyy closed 10 months ago

wwwesleyyy commented 10 months ago

Hey, thanks for building this adapter out! I'm curious how you're deploying it, because my own app deployed with SAM is throwing an error when I hit it...

{
    "errorType": "TypeError",
    "errorMessage": "Cannot read properties of undefined (reading 'pathname')",
    "stack": [
        "TypeError: Cannot read properties of undefined (reading 'pathname')",
        "    at Array.<anonymous> (file:///var/task/handler.js:18425:30)",
        "    at handle (file:///var/task/handler.js:18987:18)",
        "    at Runtime.handler (file:///var/task/handler.js:18993:5)",
        "    at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1147:29)"
    ]
}

I've built the following SAM template out:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: SAM Template for the Repo

Globals:
  Function:
    Timeout: 3

Resources:
  WebUIFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: ./web-ui/build
      Handler: handler.handler
      Runtime: nodejs18.x
      Architectures:
        - arm64
      Events:
        MyGateway:
          Type: Api 
          Properties:
            Path: /{proxy+}
            Method: ANY

My build directory is structured to include the package.json, node_modules and build artifacts as mentioned in the README...

❯ tree web-ui/build/ -L 1
web-ui/build/
├── client
├── env.js
├── handler.js
├── index.js
├── node_modules
├── package.json
└── server

If you have any suggestions on deploying this, I'd love to hear them. Thanks again!

wwwesleyyy commented 10 months ago

Updated the SAM template to set Handler: index.handler instead, and it seems to work now! :)

tessellator commented 10 months ago

Awesome! :)