setupProxy.js doesn't support Flow
See original GitHub issueIs this a bug report?
Yes.
Did you try recovering your dependencies?
Yes.
Which terms did you search for in User Guide?
“proxy” and “setupProxy”
Steps to Reproduce
-
make a
src/setupProxy.js
with Flow annotations (the “: *”) like,// @flow const proxy = require('http-proxy-middleware'); module.exports = function(app: *) { app.use(proxy('/api', { target: 'http://localhost:3001/' })); };
-
run
yarn start
Expected Behavior
The usual dev server startup
Actual Behavior
$ yarn start
yarn run v1.7.0
$ react-scripts start
Unexpected token :
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
node.js - setupProxy is not working - http-proxy-middleware
The problem is not the setupProxy.js, the problem is that the path to which axios is posting does not exist in the backend....
Read more >setupProxy.js does not work inside React App
Hello, I am having a setupProxy.js file under the src/ folder to deal with Cross-Origin Issues from localhost. However, it doesn't work and ......
Read more >Proxying API Requests in Development - Create React App
The proxy option supports HTTP, HTTPS and WebSocket connections. ... Next, create src/setupProxy.js and place the following contents in it:.
Read more >ASP.NET 6 + React APIs - Microsoft Q&A
I describe the process in my environment below hoping this will help. (1) The proxy settings are included in the setupProxy.js file:.
Read more >Proxy does not work with the React build version - JavaScript
Proxy works with 'npm start' but does not work with the React build version ... @nhcarrigan Can you please help with this? ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @Timer! Yes the normal
proxy
string does work for this use case. I was merely highlighting the incompatibility with es2015 module syntax.I stumbled upon this issue #5185 because I was experiencing the exact same “Actual Behavior”. What fixed things for me was changing my
setupProxy.js
file from this:to this:
I’m commenting incase it saves someone else time in the future.