firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Serve Dynamic Content with Express not deploys cloud function

Open georgelviv opened this issue 1 year ago • 2 comments

[REQUIRED] Environment info

firebase-tools: 13.5.0

Platform: macOS (M1)

[REQUIRED] Test case

I want to deploy react app build with vite and express.js server for SSR. I've used next code template from vite. I've followed all mentioned steps described in Serve Dynamic Content and it's deploys static content but not cloud function (express server).

server.js

import express from 'express';

export function app() {
  // Create http server
  const app = express();
  return app;
}

firebase.json

{
  "hosting": {
    "source": ".",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "frameworksBackend": {
      "region": "europe-west1"
    }
  }
}

package.json

{
  "name": "dyvoxyz",
  "type": "module",
  "directories": {
    "serve": "dist/client"
  },
  "files": ["dist/client", "server.js"],
  "main": "server.js",

[REQUIRED] Steps to reproduce

  1. Create project with react and vite, configure SSR using next code as template
  2. $ firebase experiments:enable webframeworks
  3. $ firebase init hosting
  4. Add next attributes to package.json
 "directories": {
    "serve": "dist/client"
  },
  "files": ["dist", "server.js"],
  "main": "server.js",
  1. $ firebase deploy

[REQUIRED] Expected behavior

Should deploy server.js as cloud function

[REQUIRED] Actual behavior

Deploys only static files

image

georgelviv avatar Mar 14 '24 10:03 georgelviv

Hi, Are there any updates for this issue? I am hitting the same problem.

@georgelviv , let me know if you found a work around or did you use cloud functions.

dzak83 avatar Aug 30 '24 22:08 dzak83

Update: looks like the best way to address this is to use cloud functions: https://firebase.google.com/docs/hosting/functions#use_a_web_framework

dzak83 avatar Aug 31 '24 00:08 dzak83