@arkaneel/enablecors

1.0.1 • Public • Published

@arkaneel/enablecors

A simple Node.js Middleware to enable Cross Origin Resource Sharing.

Installation

npm install @arkaneel/enablecors

Usage

const MiddleWare = require('@arkaneel/enablecors');

Examples

  • With HTTP Module
const http = require("http");
const CorsMiddleware = require('@arkaneel/enablecors');

const server = http.createServer((req, res) => {
  CorsMiddleware.EnableCors(req, res, () => {
    res.send("Hello, world!");
  });
});

server.listen(3000);
  • With Express.js
const express = require('express');
const CorsMiddleware = require('@arkaneel/enablecors');

const app = express();

app.use(CorsMiddleware.EnableCors);

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

app.listen(3000);

Package Sidebar

Install

npm i @arkaneel/enablecors

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

1.76 kB

Total Files

3

Last publish

Collaborators

  • arkaneel