Recently I have been all over my head with deploying nuxt 3 application with SSR support into AWS Amplify. Apparently even they have mentioned they support nuxt and next deployment with SSR support in here, it seems like it is quite misleading. I have tried for days to deploy it to Amplify but didn't work. After quite a digging I found these two github issues mentioning that it doesn't support SSR deployment with nuxt.
Then I turned to deploy into AWS Lambda with the use of serverless framework. I found out in this post that we could do it with nuxt 3. But it is failing with the following error Cannot find module 'my-app/.output/server/index'.
Below is my setup
serverless.yaml
service: my-app
frameworkVersion: "3"
provider:
name: aws
runtime: nodejs18.x
memorySize: 2048
stage: dev
timeout: 900
region: us-east-1
functions:
nuxt:
handler: .output/server/index.handler
events:
- httpApi: '*'
nuxt.config.ts
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
ssr: false,
nitro: {
preset: 'aws-lambda'
}
})
package.json
{
"private": true,
"scripts": {
"build": "nuxt build",
"build:lambda": "NITRO_PRESET=aws-lambda nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"deploy": "sls deploy"
},
"devDependencies": {
"@nuxt/devtools": "latest",
"@types/node": "^18.17.3",
"nuxt": "^3.6.5"
}
}
I have three queries,
SSR?serverless framework also not working with nuxt 3?SSR support into AWS?Appreciate the help for any one of my queries.
There's now a nitro preset for AWS Amplify- https://github.com/unjs/nitro/pull/1912
https://nitro.unjs.io/deploy/providers/aws-amplify
You should be able to deploy Nuxt3 apps on AWS Amplify using the preset
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With