D
D
Dmitry Maksimyuk2022-04-16 07:29:49
JavaScript
Dmitry Maksimyuk, 2022-04-16 07:29:49

Why proxy in ReactJS doesn't change url?

Front on: localhost:3000
Back on: localhost:3001
In package.json: "proxy": " localhost:3001 ",

Network tab: the request goes to localhost:3000/news
And you need to 3001.
Code to send the request:

fetch("/news")
.then((res) => console.log(res)) // url: " localhost:3000/news "
.then((arr) => console.log(arr))
.catch ((err) => console.log(err));


React version: 18.0

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question