Closed ErtyDess closed 1 year ago
i solved it adding
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, POST');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
next();
});
to the server app.js
hello i want from my react app to make a request to webssh2 app passing in post the username and userpassword
i made this code
here i call it
react is running on localhost:3000
but i always get cross origin error: has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. even if i put the origin in the webssh2 config.json.
config.json