Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

@kumarnilesh890
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant