I'm trying to run this function:
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const express = require('express');
const cors = require('cors')({origin: true});
const router = new express.Router();
router.use(cors);
router.get('*', (req, res) => {
res.setHeader('Access-Control-Allow-Origin', '*').status(200)
.send('Hello, Functions');
});
exports.date = functions.https.onRequest(router);
However, I encountered the following error:
XMLHttpRequest cannot load . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '' is therefore not allowed access. The response had HTTP status code 500.