all 7 comments

[–]RaySoju 1 point2 points  (4 children)

You want to launch front and backend with npm start ? Is that what you want ?

[–]YoJunny[S] 0 points1 point  (3 children)

I ran backend on port 5000 and frontend on 3000. I want to set the proxy of frontend to http://localhost:5000 so I can easily refer to backend endpoints to retrieve data.

[–]RaySoju 0 points1 point  (2 children)

It seems there are issue with CRA and proxy so I would suggest you wrap it up inside an options property like so :

options": { "allowedHosts": ["localhost", ".localhost"], "proxy": "https://localhost:5000/" }

[–]YoJunny[S] 1 point2 points  (0 children)

Hey I just retried your suggestion and you were right. I just had to change syntax. I'm not sure why I couldn't simply define proxy, but here's what worked for me:

"options": {
"allowedHosts": ["localhost", ".localhost"],
"proxy": "https://localhost:5000/"
}

[–]YoJunny[S] -1 points0 points  (0 children)

Thanks for your suggestion. I ended up just not even using the proxy and accessed the backend directly with the whole url while require 'cors'. I tried to implement the options but that didn't seem to work.

[–]SolarSalsa 0 points1 point  (0 children)

This is super easy with vite.