Rob--W / cors-anywhere

CORS Anywhere is a NodeJS reverse proxy which adds CORS headers to the proxied request.
MIT License
8.5k stars 5.92k forks source link

createServer is not a function #442

Closed niebieskiRydz closed 1 year ago

niebieskiRydz commented 1 year ago

Hello, I am developing app in React.js

I installed cors-anywhere and imported it with: const cors_proxy = require('cors-anywhere');

I have set the host and the port.

When I'm trying to use: cors_proxy.createServer({ originWhitelist: [], // Allow all origins requireHeader: ['origin', 'x-requested-with'], removeHeaders: ['cookie', 'cookie2'] }).listen(port, host, function() { console.log('Running CORS Anywhere on ' + host + ':' + port); });

I get an error: Uncaught (in promise) TypeError: __webpack_require__(...).createServer is not a function createServer cors-anywhere.js:424

Do you have any idea what can I do to make it work?

Thank you in advance.

Rob--W commented 1 year ago

This is a Node.js library that should run on a server. It doesn't work in a web browser.

niebieskiRydz commented 1 year ago

It works well now on a server. Thank you.