Allowing CORS in NodeJS runtime

PHOTO EMBED

Sun Jul 10 2022 08:36:11 GMT+0000 (Coordinated Universal Time)

Saved by @jadorkor #javascript #nodejs

import cors from "cors"; //ES6
const cors = require("cors"); //commonjs

const corsOptions = {origin: "*", methods: ["GET, HEAD, PUT, PATCH, POST, DELETE"], credentails: true, optionsSuccessStatus: 200};
app.use(cors(corsOptions));
content_copyCOPY

Allowed cors functionality with frontend requests from different domain