question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

proxy in package.json not working

See original GitHub issue

I have defind a proxy url in package.json but it getting my localhost url before api path

{
  "name": "fanmojoReact",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "babel-core": "^6.20.0",
    "babel-loader": "^6.2.9",
    "babel-preset-es2015": "^6.18.0",
    "babel-preset-react": "^6.16.0",
    "css-loader": "^0.26.1",
    "eslint": "^3.12.2",
    "eslint-config-standard": "^6.2.1",
    "eslint-config-standard-react": "^4.2.0",
    "eslint-plugin-node": "^3.0.5",
    "eslint-plugin-promise": "^3.4.0",
    "eslint-plugin-react": "^6.8.0",
    "eslint-plugin-standard": "^2.0.1",
    "react-scripts": "0.8.4",
    "style-loader": "^0.13.1",
    "sw-precache": "^4.2.2",
    "sw-precache-webpack-plugin": "^0.7.0",
    "webpack": "^1.14.0"
  },
  "dependencies": {
    "es6-promise": "^4.0.5",
    "isomorphic-fetch": "^2.2.1",
    "lodash": "^4.17.4",
    "react": "^15.4.1",
    "react-dom": "^15.4.1",
    "react-redux": "^5.0.1",
    "react-router": "^3.0.0",
    "react-router-redux": "^4.0.7",
    "redux": "^3.6.0",
    "redux-act": "^1.1.0",
    "redux-logger": "^2.7.4",
    "redux-router": "^2.1.2",
    "redux-saga": "^0.13.0",
    "webpack-dev-server": "^1.16.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build && sw-precache --config=sw-precache-config.js",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "proxy": "http://172.21.25.169:3000"
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:30 (7 by maintainers)

github_iconTop GitHub Comments

33reactions
viankakrisnacommented, Jan 12, 2017

how do you test your proxy? using fetch / ajax / browser direct to url? the proxy in create react app only works when it’s a fetch or ajax request.

12reactions
viankakrisnacommented, Jan 12, 2017

https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#proxying-api-requests-in-development

The development server will only attempt to send requests without a text/html accept header to the proxy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

proxy not working for react and node - Stack Overflow
Delete package-lock.json and node_modules in React app · Turn off React Terminal and npm install all dependencies again on React App · Turn...
Read more >
Setting Proxy in package.json for React not working?
Hey guys, I'm trying to create a React app and adding a node server in the same repo. I am following this article: ......
Read more >
proxy not working like expected : r/reactjs - Reddit
so I am creating a small react project and I have currently creating a registration form that checks if the username and the...
Read more >
React Proxy | Easiest Fix to CORS Errors - YouTube
Proxying API Requests in Development using Vite, Parcel, or Create React App. If your plan is to host your react app from the...
Read more >
React — How To Proxy To Backend Server - Medium
If you change the port in the proxy value in the package.json proxying calls to the API will not work. Create React App...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found