0

I'm trying to deploy a Vite+React+SSR app to Firebase, but Firebase won't recognize the runtime for my server script. I've created a file – server/index.js – running Express.js for SSR rendering of the app, which works fine locally. In the same file I've added onRequest from Firebase to handle SSL.

import express from 'express'
import { onRequest } from 'firebase-functions/v2/https'

const app = express()
app.use(/* Express and Vite settings */)
app.listen(process.env.PORT)

export const ssr = onRequest(app)

Here's my Firebase config:

{
  "hosting": {
    "public": "dist/client",
    "ignore": [
      "**/.*",
      "**/node_modules/**",
      "firebase.json",
      "firebase-debug.log",
      "firebase-debug.*.log"
    ],
    "rewrites": [
      {
        "source": "**",
        "function": "ssr"
      }
    ]
  },
  "functions": [
    {
      "source": "server",
      "runtime": "nodejs22",
      "codebase": "default"
    }
  ]
}

Package.json:

{
  "name": "name",
  "version": "0.1.0",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "rimraf dist && pnpm build:client && pnpm build:server",
    "build:client": "vite build --outDir dist/client --ssrManifest",
    "build:server": "vite build --ssr src/entry-server.tsx --outDir dist/server",
    "deploy": "firebase deploy --only functions",
    "serve": "pnpm build && firebase emulators:start --only functions",
    "shell": "pnpm build && firebase functions:shell",
    "start": "firebase functions:shell"
  },

  // ...Dependencies & devDependencies

  "engines": {
    "node": "22"
  }
}

I've tried with node 20 and node 22, to no avail.

1
  • 1
    Please edit the question to state what you're doing that causes the problem, in addition to the exact error message. Also you should indicate which version of the Firebase CLI you're using. The documentation is clear about which runtimes are supported, and I can say that I use 20 on a daily basis: firebase.google.com/docs/functions/… Commented Jan 30 at 13:43

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.