I want to access Apis in Deno server from a React app. I added proxy
to the package.json file but I got this error:
options.allowedHosts[0] should be a non-empty string.
I found a similar question Invalid options object. Dev Server has been initialized using an options object that does not match the API schema, I followed the answer by installing the http-proxy-middleware
in the react project and add the setupProxy
under the src folder:
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/',
createProxyMiddleware({
target: 'http://localhost:5000',
changeOrigin: true,
})
);
};
I followed also what mentioned in the documentation, however I still have the same 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.
I'm using react-scripts v5.0.0
and typescript v4.6.2
.