0

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.

  1. https://github.com/nuxt/website-v2/issues/1091
  2. https://github.com/aws-amplify/amplify-hosting/issues/1860

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,

  1. Is Amplify approach not possible yet with SSR?
  2. Is Lambda deployment with serverless framework also not working with nuxt 3?
  3. If above are not options, what would be the best approach to deploy a nuxt 3 application with SSR support into AWS?

Appreciate the help for any one of my queries.

0 Answers0