Skip to content

Webframeworks do not deploy nextjs ssr{projectId} function when using project aliases #5880

Open

Description

@pzmudzinski

[REQUIRED] Environment info

firebase-tools:12.1.0

Platform:macOS

[REQUIRED] Test case

Repository with two firebase projects set as aliases. Add Nextjs project inside it.
This is hosting setting from firebase.json:

  "hosting": [
    {
      "target": "cms",
      "source": "cms",
      "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
      "frameworksBackend": {
        "region": "us-central1"
      }
    }
  ],

[REQUIRED] Steps to reproduce

firebase use {alias}
firebase deploy --only hosting

[REQUIRED] Expected behavior

ssr{projectId} function should be deployed but it does not and see warning in deploy command:

hosting[...]: Unable to find a valid endpoint for function `ssr...`, but still including it in the config

I got it working when using default project. It stopped working after adding new project alias and trying to deploy the same website under different project. I am assuming that's the reason but maybe something got broken with latest versions of CLI?

[REQUIRED] Actual behavior

After deploying page returns 404.
Logs attached:

logs.txt

Activity

  1. pzmudzinski commented on May 23, 2023

    @pzmudzinski
    Author

    Update: downgrading firebase-tools back to 11.30.0 fixes the issue so this is definitely buggy there ❗

  2. Snugug commented on Jun 2, 2023

    @Snugug

    I'm having a similar problem with Astro (so can't downgrade to 11.x). When trying to deploy, I get the following output after successfully building the static bits of my site:

    i  hosting: The following function(s) are pinned to site {projectId} and will be deployed as well: ssr{projectId}
    
    === Deploying to '{projectId}'...
    
    i  deploying functions, hosting
    
    Error: No function matches given --only filters. Aborting deployment.
     ELIFECYCLE  Command failed with exit code 1.
    

    I'm using Astro hybrid rendering.

    I'm not using project aliases.

  3. rodydavis commented on Jun 8, 2023

    @rodydavis

    I'm having a similar problem with Astro (so can't downgrade to 11.x). When trying to deploy, I get the following output after successfully building the static bits of my site:

    i  hosting: The following function(s) are pinned to site {projectId} and will be deployed as well: ssr{projectId}
    
    === Deploying to '{projectId}'...
    
    i  deploying functions, hosting
    
    Error: No function matches given --only filters. Aborting deployment.
     ELIFECYCLE  Command failed with exit code 1.
    

    I'm using Astro hybrid rendering.

    I'm not using project aliases.

    This is happening with astro standalone mode too:

    output: 'server',
      adapter: node({
        mode: "standalone"
      }),
    
  4. 123ndy commented on Jun 24, 2023

    @123ndy

    I had the same problem (Error: No function matches given --only filters. Aborting deployment.).

    Seems like it is happening when Firebase tries to create an SSR function ("under the hood") to do some work on the images in the project.

    In my initial project, I had initially run the firebase init hosting command, thus I had no functions folder and no reference to it in my firebase.json file. That seems to be the root cause of the problem - seems like you need a functions folder, with some initial files and a reference to it:

    I added the following to my firebase.json

    "functions": [
        {
          "source": "functions",
          "codebase": "default",
          "ignore": [
            "node_modules",
            ".git",
            "firebase-debug.log",
            "firebase-debug.*.log"
          ]
        }
      ]
    

    And added a functions folder with an empty index.js file and a package.json file with the following code:

    {
        "name": "functions",
        "description": "Cloud Functions for Firebase",
        "scripts": {
            "serve": "firebase emulators:start --only functions",
            "shell": "firebase functions:shell",
            "start": "npm run shell",
            "deploy": "firebase deploy --only functions",
            "logs": "firebase functions:log"
        },
        "engines": {
            "node": "16"
        },
        "main": "index.js",
        "dependencies": {},
        "devDependencies": {},
        "private": true
    }
    

    When running the Firebase deploy command (for example firebase hosting:channel:deploy new-awesome-feature --expires 7d now, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions