Piotr
Piotr

Reputation: 53

How to access local api on the deployed firebase application?

I have created a simple todo app for learning purposes. It is a full stack website that consists of a static html file with js script that is accessing api on the same host. Backend is build on node.js with express framework and mongodb. Everything works fine on a local server, that I start with cmd:

firebase serve --only functions,hosting

However when I deploy the app to the firebase cloud with cmd:

firebase deploy

I cannot access JSON file that should be served under /api/todos. Instead I receive 503 error: enter image description here

The app/api/todos also does not work and gives error: Cannot GET /app/api/todos

I can access the file locally:enter image description here

How can I access my JSON file after the deployment? How the route /app/api/todos would be translated in the app that is deployed?

Upvotes: 0

Views: 371

Answers (1)

Michele Della Mea
Michele Della Mea

Reputation: 156

You should rewrite your /api route from hosting to functions in firebase.json file

Take a look to this link

Upvotes: 2

Related Questions