Skip to content
This repository has been archived by the owner on Oct 24, 2019. It is now read-only.

Proxy in package.json #6

Closed
vincezun opened this issue Apr 23, 2019 · 7 comments
Closed

Proxy in package.json #6

vincezun opened this issue Apr 23, 2019 · 7 comments

Comments

@vincezun
Copy link

Adding proxy in package.json is not working but if I add it directly in axios.get() it is working.
This is what I get when it is from the proxy in package.json
image

And when I npm start I'm getting this DeprecationWarning
image

Already tried proxy in package.json in create-react-app and it is working.
image

@Butonix
Copy link

Butonix commented Apr 23, 2019

Adding proxy in package.json is not working but if I add it directly in axios.get() it is working.
This is what I get when it is from the proxy in package.json
image

And when I npm start I'm getting this DeprecationWarning
image

Already tried proxy in package.json in create-react-app and it is working.
image

I, too, wrote about this author, but he ignored me! There is no support, so it is better not to use this repository!

@vincezun
Copy link
Author

Maybe they are busy, so we wait...

@Butonix
Copy link

Butonix commented Apr 23, 2019

Maybe they are busy, so we wait...

No, he just silently closed my question.
Try razzle he's a lot better

@maxparelius
Copy link
Contributor

@vinzun @Butonix proxy is much different behavior with ssr so it does not work the same as in cra. I am not sure why you need a proxy. Any request from the browser goes to the rendering server by default. If you want it to go somewhere else just use the full url. If you really want a proxy you can implement it at the node level in the rendering server.

@vincezun
Copy link
Author

Thanks for the info. I am new to this, learning new stuffs. I also tried it with different framework and noticed that it's not working with any ssr. I'm trying to research about this and spent a lot of time. Thanks again bro!

@maxparelius
Copy link
Contributor

@vinzun what does your stack look like? Generally a proxy is useful when you want some route (e.g. /my_profile) to go somewhere else other than the server that served the app. With CRA its useful since the app is served by a webpack dev server and api requests are not handled by that server. So a proxy allows to send api requests to the api server. In my stack I generally use a single node server just for rendering. Create React SSR App comes with this server configured. I then use a different server (rails, node, go, or something else) to handle API requests. In my client code I use the full url for API requests (e.g. http://localhost:3000/my_profile rather than /my_profile) so which makes proxy unecessary.

@vincezun
Copy link
Author

Im creating a website using React and WP Rest Api, it just got me thinking about how headless cms will be called when it comes to production.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants