Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
Created by: slim-hmidi
Describe the bug
I'm trying to access the Apis in my local server throug the react app and I got this issue:
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.
Did you try recovering your dependencies?
8.3.1
Which terms did you search for in User Guide?
proxy in local environment
Environment
System:
OS: Windows 10 10.0.19044
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 8.3.1 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: Not Found
Edge: Spartan (44.19041.1266.0), Chromium (100.0.1185.44)
Internet Explorer: 11.0.19041.1566
npmPackages:
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-scripts: 5.0.0 => 5.0.0
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
(Write your steps here:)
- Install http-proxy-middleware
- Create
setupProxy
and add this code:
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/',
createProxyMiddleware({
target: 'http://localhost:5000',
changeOrigin: true,
})
);
};
- npm start
Expected behavior
The app should be started normally.
Actual behavior
I got this error:
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.