CORS and NodeJS with Express

If you’re building an RESTfull API with NodeJS (and Express), you’ll probably need CORS.
Otherwise nobody will be able to user your public API via Browsers.
So this is important vor Third-Party JQuery, Angular, whatever… Clients.

With this small Piece of Code you could make your API public and answer the CORS (Preflight) Requests.

This small function can be used via:
var express = require('express');
var app = express();

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *