Skip to content

Instantly share code, notes, and snippets.

@Gaurav8757
Created May 20, 2024 10:53
Show Gist options
  • Select an option

  • Save Gaurav8757/c69ca224a2bac997e7affb2fe3f3fb71 to your computer and use it in GitHub Desktop.

Select an option

Save Gaurav8757/c69ca224a2bac997e7affb2fe3f3fb71 to your computer and use it in GitHub Desktop.
ES6 .ENV code
import dotenv from "dotenv";
dotenv.config();
const {CORS, CORS1, CORSLOCAL} = process.env;
const corsOptions = {
origin: [CORS, CORS1, CORSLOCAL], // Specify trusted domains
methods: ['GET', 'POST'], // Specify allowed methods
allowedHeaders: ['Content-Type', 'Authorization'] // Specify allowed headers
};
app.use(cors(corsOptions));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment