# Internal Server Error when accessing Lambda

**URL:** <https://forum.serverless.com/t/internal-server-error-when-accessing-lambda/17041>\
**Category:** Serverless Framework\
**Created:** [April 16, 2022, 6:38am UTC](https://forum.serverless.com/t/internal-server-error-when-accessing-lambda/17041 "2022-04-16T06:38:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joaocasarin](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/joaocasarin/32/6756_2.png) [@joaocasarin](https://forum.serverless.com/u/joaocasarin)\
**Post date:** [April 16, 2022, 6:38am UTC](https://forum.serverless.com/t/internal-server-error-when-accessing-lambda/17041/1 "2022-04-16T06:38:10Z")

</div>

So, I have deployed an app to lambda using serverless.

When I try to GET my lambda endpoint, this is all I get:

```json
{
  "message": "Internal server error"
}

```

In the console I got error 403 for the favicon, and 502 for the request.

These are my files:

`serverless.ts`:

```nohighlight
import type { AWS } from '@serverless/typescript';
import functions from './serverless/functions';

const serverlessConfiguration: AWS = {
    service: 'lambda-ts',
    frameworkVersion: '3',
    plugins: ['serverless-esbuild'],
    provider: {
        name: 'aws',
        runtime: 'nodejs14.x',
        apiGateway: {
            minimumCompressionSize: 1024,
            shouldStartNameWithService: true
        },
        environment: {
            AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
            NODE_OPTIONS: '--enable-source-maps --stack-trace-limit=1000'
        }
    },
    // import the function via paths
    functions,
    package: { individually: true },
    custom: {
        esbuild: {
            bundle: true,
            minify: false,
            sourcemap: true,
            exclude: ['aws-sdk'],
            target: 'node14',
            define: { 'require.resolve': undefined },
            platform: 'node',
            concurrency: 10
        }
    }
};

module.exports = serverlessConfiguration;

```

`serverless/functions.ts`:

```nohighlight
import { AWS } from '@serverless/typescript';

const functions: AWS['functions'] = {
    example: {
        handler: 'src/lambdas/example/index.handler',
        events: [
            {
                http: {
                    method: 'get',
                    path: 'example',
                    cors: {
                        origin: '*'
                    }
                }
            }
        ]
    }
};

export default functions;

```

And this is my `src/lambdas/example/index.ts`:

```nohighlight
import { APIGatewayProxyEvent, APIGatewayProxyHandler, APIGatewayProxyResult } from 'aws-lambda';

const handler: APIGatewayProxyHandler = async (
    event: APIGatewayProxyEvent
): Promise<APIGatewayProxyResult> => {
    try {
        const { queryStringParameters } = event;
        return {
            statusCode: 200,
            body: JSON.stringify({
                queryStringParameters: JSON.stringify(queryStringParameters) || '{}'
            })
        };
    } catch (e) {
        return {
            statusCode: 500,
            body: JSON.stringify({
                error: (e as Error).message
            })
        };
    }
};

export default handler;

```

I hope someone can help me, I have just started learning lambda/serverless.
