You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cess to XMLHttpRequest at 'http://localhost:8080/api/payment/orders' from origin 'http://localhost:3000' 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. xhr.js:210
#483
Open
kumarnilesh890 opened this issue
May 2, 2023
· 0 comments
const express = require("express");
const cors = require("cors");
const dotenv = require("dotenv");
const paymentRoutes = require("./Routes/payment");
const app = express();
dotenv.config();
app.use(express.json());
app.use(cors());
app.options('', cors());
app.use(
cors({
origin: true,
optionsSuccessStatus: 200,
credentials: true,
})
);
app.options(
'',
cors({
origin: true,
optionsSuccessStatus: 200,
credentials: true,
})
);
app.use("/api/payment/", paymentRoutes);
// const corsOrigin ={
// origin:'http://localhost:3000', //or whatever port your frontend is using
// optionSuccessStatus:200,
// methods: "GET, POST"
// }
// app.use(cors(corsOrigin));
// app.use(cors());
// app.get("/", (req,res)=>{
// res.send("server working");
// });
const port = process.env.PORT || 5001;
app.listen(port, () => console.log(
Listening on port ${port}...
));The text was updated successfully, but these errors were encountered: