1
votes

I have a NextJS app and an express.js API both hosted in Firebase Cloud Functions.

This is my firebase.json

{
    "hosting": {
        "public": "src/public",
        "rewrites": [
            {
                "source": "/user",
                "function": "api"
            },
            {
                "source": "/users",
                "function": "api"
            },
            {
                "source": "**/**",
                "function": "next"
            }
        ]
    },
    "functions": {
        "source": "src/functions"
    }
}

What I expecting was to rewrite /user and /users to api Cloud Function and all other URL to next Cloud Function. But it not working as I expected. Every URL is passing to next Cloud Function even /user and /users. And I need help...

1
What exactly is not working the way you expect? Please be specific. Is it one of the rewrites? Or all three? What is actually happening in the case that it doesn't do what you want? - Doug Stevenson
every url is using next cloud function even /user and /users - z3r0c00l_2k

1 Answers

1
votes

Try the below code, you can find its used on an example of the documentation that is intended for requests to files or directories that do not exist, including all other replies I understand

// Serves index.html for requests to files or directories that do not exist
 "source": "**",
 "function": "next"