Skip to content

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

Description

@kumarnilesh890

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}...));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions