score:1
Accepted answer
because you have the proxy specified in your package.json, when you make the request from the client to the server, you want to leave off the origin part of the url.
this should be changed to
componentdidmount() {
fetch('http://localhost:8080/xxxx')
.then(response => response.json())
.then(xxxx=> this.setstate({ xxxx }, () => console.log("successfully fetched xxxx", xxxx)));
}
this
fetch('/xxxx')
.then(response => response.json())
.then(xxxx=> this.setstate({ xxxx }, () => console.log("successfully fetched xxxx", xxxx)));
}
essentially you will only specify the actual endpoint and leave the origin off, this will now allow webpack dev server to proxy your request to your express server.
score:0
chaim's answer above worked! thanks
Source: stackoverflow.com
Related Query
- Can't get a proxy server working on react app for local mysql database
- Create React App proxy to express server for PassportJS not working
- Set up proxy server for create react app
- Connecting my React App to a MySQL Database on a PHP Server
- Storing layout for my react app in local storage not working
- Axios get request from local server url from within React app
- proxy not working for react and node
- Cant load a react app after starting server
- How to get sourcemaps working for React Css Modules?
- eslint error on deployment on local server of react web app
- eslint error on deployment on local server of react web app
- React app is looking for static files in different location when using proxy
- React Native fetch a local server using a proxy
- How to get Font Awesome Icon in react app for a pseudo element in css
- Cannot disable LiveReloading webapck dev server for my react app
- Can't redirect with a proxy to Node server when hosting a React app on AWS S3 bucket
- NGINX proxy pass to React App not working
- How to deploy a react app that does not have index.html on an apache server for production
- Cant start React simple app I get Error: Element type is invalid: expected a string
- React app set proxy not working with docker compose
- Zip File Download via Axios from Express Server not working in React App
- Trying to get react-perfect-scrollbar working in React app
- react app doesn't read correct path for assets folder - local images don't show up on localhost, only shows an image icon
- Working example for Graph Toolkit using SharePoint spfx, React and Get component with template
- Proxy request error when trying to send post request from React to Node, proxy is working fine on get requests
- Deploying a React + NodeJS + Express + MySQL App to Heroku only deploying the Server Not the React
- CORS policy: The 'Access-Control-Allow-Origin' problem when deployed NextJS app on Nginx server tries GET request to local Express server
- Unable to get env variables in public/index.html for react app
- http-proxy-middleware proxy is not working in React js and Spring Boot project. GET API is return 415 status error
- Monaco editor in react app with language server for python intellisense
More Query from same tag
- How to change outputDir (/build) of TypeScript code in create-react-app
- MobX not rerendering React component as used @computed is changed
- My Apache server is displaying a directory listing instead of serving my files -- how do I configure it properly?
- How to render multiple dynamic options into select box in React from Axios
- Returning a dispatch with promises in action creators of react redux
- react open file browser on click a div
- Hook error in Route Container component using useParams
- React child component not updating when props change
- How to pass my error message from server called by axios to my component
- is it possible to display number of week in row with selected week?
- Error 403 forbidden when using React Router with Apache
- is this valid for getting input state value?
- Equivalent of arrow function in react is not working
- Toggle twice to open and close the sidebar menu
- How to migrate componentWillReceiveProps in react 16.0.0?
- incorporating theme into react-minimal-pie-chart does not work
- Writing Element({...props}) instead of Element(props)
- Can not apply custom theme in MUI react
- After using react-router the onClick event is not firing the function in first time and works fine after that
- How do I center an avatar element that is within a cardHeader component?
- ReactJS app using Three.JS. How to render the VRButton?
- Limit table to 15 rows and click on "Load more" to load more 15 rows in React JS
- How can I vertically stack left, right, and center columns in that order with reactstrap on md breakpoint?
- React useContext, useRedux child component does not update
- How to lift multiple values in state from a form submission?
- React downloads pending images of previous render
- Two separately routes in react router
- Bottom navigation disappears when route clicked
- Efficiently computing derived data from react props
- how to make tooltip for TextField material ui react hooks