Pergunta de entrevista da empresa Totality Corp

What are CORS (Cross Origin Resource sharing)?

Resposta da entrevista

Sigiloso

15 de mai. de 2024

CORS stands for Cross-Origin Resource Sharing, which allows communication between different domains. By default, we cannot access other APIs on the web and mobile, so in the backend, we need to add CORS. For example, if we are building our backend using Node.js and Express, we can use the 'cors' package available on npm. We can simply install it and use it like this: ```javascript const express = require("express"); const cors = require("cors"); const app = express(); app.use(cors()); // This will allow all origins ```