-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Question: How to proxy requests in production? #2386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@patwalls hi! You need to set this up yourself; most likely on the rails side. Even if rails only serves the |
You might find this blog post really handy. x-ref: #1358 |
Closing this as answered. Let us know if you have more problems! |
Sorry I didn't respond. I went with the latter option you explained. I used the I'm curious, do you know of any good boilerplate that has rails backend, create-react-app frontend built into one repo and maybe even have a good heroku/AWS buildpack ready to go? Would be interested to take a look. |
Im not sure what your stack is but something which is working for me in development and in productions is to use the |
In my case, I have an phoenix backend hosted on Heroku and a react app static build on S3. I'm pretending to use create-react-app for my frontend to get its benefits (I'm using old configs with webpack v1). How can I make requests to it without hardcode the Endpoint url string on the "fetch" function, preserving the call like this |
Make I an environment variable something like process.env.REACT_APP_API_DOMAIN. Make sure it is set when you build (Netfliy let’s you set env vars, of building locally can use cross-env or dotenv |
Netlify has been great for me for hosting |
Thanks @mjsisley and @patwalls . In my webpack v1 config, I'm using an API_HOST variable configured through the webpack's Define Plugin, it exposes globally in my js files the variable, so that I'm using my fetch functions like: |
In my case, I am having java backend hosted on AWS EB and a react app on S3. After concatenating my requests with API-server URL, I am getting an empty response. Why is so? Is there an issue of CORS? |
I feel like an idiot...
I have create-react-app and a Rails 5 API. All requests should hit the rails server, and I was able to use the proxy feature in
package.json
, which is awesome!But how do I do this in production? In production my rails server can't live at the same domain as my create-react-app right, unless I am missing something?
Thanks for your help.
The text was updated successfully, but these errors were encountered: