Не запускается реакт приложение с полем proxy
Добрый день или же вечер, когда я пытался связать бек и фронт(бек я писал на express.js, а фронт на реакте), и попытался добавить в package.json поле proxy со значением "http://localhost:5000", то вылетает такая ошибка:
Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.allowedHosts[0] should be a non-empty string.
Вот что у меня на реакте написано:
import React, { useEffect } from 'react'
export default function App() {
useEffect(() => {
fetch('/messages')
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err))
}, [])
return (
<div>
<h1>Привет мир!</h1>
</div>
)
}
Вот что в беке:
import express from 'express'
const PORT = process.env.PORT || 5000
const app = express()
const messages = []
app.use(express.json())
app.listen(PORT, () => {
console.log(`Server has been started on port ${PORT}`);
})
app.get('/messages', (req, res) => {
res.send(messages)
})
app.post('/messages', (req, res) => {
messages.push(req.body)
})