vuefire
vuefire copied to clipboard
Customize cookie minting auth endpoint path
What problem is this solving
When "sessionCookie" is enabled the endpoint generated is on "/api". To my knowledge, there's no option to change that endpoint path. The problem is that our current setup includes a reverse proxy via Firebase Hosting that points to a Cloud Run instance serving a custom api.
firebase.json
{
// ...firebase config,
"hosting": [
{
"site": "my-site",
"public": "path/to/nuxt/client/bundle"
"rewrites": [{ "source": "/api", "run": { "serviceId": "cloud-run-random-api", "region": "us-central1" } }]
}
]
}
The minting endpoint running on the Nuxt server never gets hit because the Firebase Hosting reverse proxy catches it first and sends it off to the Cloud Run instance. Firebase Hosting rewrites don't trim off the "source" path when forwarding the request so in the cloud run instance the request handlers have to be prepended such as "/api/actual-route/".
Due to this hard coded handler path we would prefer not to change the hosting rewrite itself.
Proposed solution
If the nuxt plugin could allow designating the cookie minting path name that would be ideal.
{
// ...nuxt config,
vuefire: {
config: { /* firebase config */ },
auth: {
enabled: true,
sessionCookie: true,
// would generate "/mint" nuxt server route
mintingRouteName: "mint"
}
}
}
Describe alternatives you've considered
Changing source code of other api servers in our infrastructure so that Firebase Hosting rewrites don't conflict with the nuxt minting server route. Requires too many changes in both front end apps and the back end api route definitions. Would prefer to avoid this.