Skip to content

Instantly share code, notes, and snippets.

@mediavrog
Last active April 14, 2023 08:56
Show Gist options
  • Star 33 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save mediavrog/49c4f809dffea4e00738a7f5e3bbfa59 to your computer and use it in GitHub Desktop.
Save mediavrog/49c4f809dffea4e00738a7f5e3bbfa59 to your computer and use it in GitHub Desktop.
CORS in Google Cloud Functions for Firebase
const cors = require('cors')({origin: true});
exports.sample = functions.https.onRequest((req, res) => {
cors(req, res, () => {
res.send('Passed.');
});
});
@rgbskills
Copy link

Hello, Im getting the cors error and I can figure out why, here is may code:

import express from "express";
import cors from "cors";

const expressApp = express();
expressApp.use(cors({origin: true}));

expressApp.get("/Hello", (req, res) => {
  res.send("Hello!");
});

Can anyone help me out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment