Reputation: 2733
I'm working on a React project with two node apps:
Client
: Frontend code using React JS and Axios for making requests to my backend service.API
: Backend service using Mongoose to connect to MongoDB and Express for handling restful requests.I had a couple questions:
What I've currently done:
api.yaml
to my API service subdirectory.gcloud app deploy client/app.yaml api/api.yaml
which deploys two services (frontend and backend).Is this a good approach?
If so, the challenge I'm now facing is that my API service is deployed to a subdomain and requests from my frontend are failing. Locally I am using the proxy
value to proxy requests to my backend port on localhost, but I'm not sure how to modify my app to dynamically make backend requests to the correct subdomain when in the production environment (I also think CORS comes into play).
Upvotes: 1
Views: 1216
Reputation: 1079
You need a dispatch.yaml file. The dispatch.yaml allows you to override routing rules. You can use the dispatch.yaml to send incoming requests to a specific service (formerly known as modules) based on the path or hostname in the URL.
Upvotes: 3