I try to deploy simple Nuxt 3 application to AWS Lambda for SSR. So far I have:
in nitro.config.ts
import { defineNitroConfig } from 'nitropack';
export default defineNitroConfig({
preset: 'aws-lambda',
serveStatic: true
});
in Lambda handler
import { handler } from './output/server/index.mjs';
export const runner = (event, context) => {
const { statusCode, headers, body } = handler({ rawPath: '/' });
return {
statusCode,
body,
headers
}
}
in serverless.yaml
functions:
ssr:
handler: handler.runner
timeout: 15
package:
individually: true
include:
- output/**
events:
- httpApi:
path: '*'
method: '*'
I run yarn build
, change .output
folder name to output
to be able to include it with package, but I still have errors like "errorMessage": "SyntaxError: Cannot use import statement outside a module"
.
Is someone has idea how it could be done?