I'm running my backend in a firebase funcion with this code
// Nest Dependencies
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ExpressAdapter } from '@nestjs/platform-express';
// Firebase Functions Dependencies
import * as functions from 'firebase-functions';
import * as express from 'express';
// Create a express server
const server = express();
const cors = require('cors');
// Create a NestServer With the Express server
const createNestServer = async (expressInstance: any): Promise<void> => {
const app = await NestFactory.create(
AppModule,
new ExpressAdapter(expressInstance),
);
//Inititlize it
await app.init();
};
// Create the google cloud function with the Nest Server(express server)
export const v1 = functions.https.onRequest(async (request, response) => {
await createNestServer(server);
server.use(cors({origin:true}))
server(request, response);
});
But I'm getting This CORS error in my React frontend
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://dev-api.mytingo.com/v1/user/teacher/groups/active?idTeacher=179. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
What I'm missing ? Thanks for your Help