Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
See original GitHub issueDescribe 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.
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:15
Top Results From Across the Web
Invalid options object. Dev Server has been initialized using ...
Here is a workaround. Delete "proxy": "http://localhost:6000". Install package http-proxy-middleware with command npm install ...
Read more >Invalid options object. Dev Server has been initialized using ...
To solve the error Invalid options object. Dev Server has been initialized using an options object that does not match the API schema,...
Read more >Dev Server has been initialized using an options object that ...
This is the error response after yarn start. Invalid options object. Dev Server has been initialized using an options object that does not...
Read more >invalid options object. dev server has been initialized - You.com
webpack.config.js [webpack-cli] Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
Read more >Setting up the Webpack Dev Server - Three.js Tutorials
[webpack-cli] Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options has...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Workaround: set env
DANGEROUSLY_DISABLE_HOST_CHECK=true
Getting this issue without configuring
http-proxy-middleware
.To reproduce:
npx create-react-app some-app
some-app/package.json
to add"proxy": "http://localhost:4000"
HOST=something.local npm run start
You shall see the following logged in your terminal.
Configuration