I am trying to understand why the preflight error is coming here because my Cors code works for Google.
Access to fetch at ‘localhost: 3001/start-automation’ from origin ‘poodleaizoomapp . serveo . net’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: 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.
The backend port is 3001.
Backend server code: I have added the Cors option, but it is not working. I also tried a different pktriot server, but the same issue.
Code:
// CORS configuration
const corsOptions = {
origin: ["poodleaizoomapp . serveo . net", "google . com"],
allowedHeaders: ["Content-Type"],
};
// app.use(cors(corsOptions)); // Enable CORS with options
app.options(
"/start-automation",
(req, res, next) => {
console.log("helo");
next();
},
cors(corsOptions)
);
// WebSocket setup
app.post("/start-automation", cors(corsOptions), (req, res) => {
const { MeetingLINK, MeetingHOST } = req.body;
if (!MeetingLINK || !MeetingHOST) {
return res
.status(400)
.json({ error: "MeetingLINK and MeetingHOST are required." });
}
startPlaywrightAutomation(MeetingLINK, MeetingHOST);
return res.status(200).json({ message: "Automation started successfully." });
});
app.get("/hello", cors(corsOptions), (req, res) => {
console.log("hello");
res.sendStatus(200);
});
app.get("/hello", cors(corsOptions), (req, res) => {
console.log("hello");
res.sendStatus(200);
});
I have added google . com to check if my cors is working there, and it is.
fetch(‘localhost: 3001/hello’, {method: ‘GET’})
-
Promise {}
-
[[Prototype]]: Promise
1. catch: ƒ catch()
2. constructor: ƒ Promise()
3. finally: ƒ finally()
4. then: ƒ then()
5. Symbol(Symbol.toStringTag): "Promise"
6. [[Prototype]]: Object
- [[PromiseState]]: “fulfilled”
- [[PromiseResult]]: Response
As you can see, the cors is working for google.com, but it does not work in the zoom console of poodleaizoomapp . serveo . net. The same 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.
My frontend is working in localhost:3000
Snyder>ssh -R poodleaizoomapp . serveo .net:80:local host:3000 serveo . net
Forwarding HTTP traffic from poodleaizoomapp . serveo . net
I need help because, currently, I need to send data from the Zoom app to my backend.
Note: I have removed HTTP because a new user in the Zoom dev forum can’t add more than two links. This is an absurd rule.