You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cors-for-lambda

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cors-for-lambda

Apply CORS Headers for Lambda HTTP responses

1.0.1
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

cors-for-lambda

"cors-for-lambda", is designed to apply CORS Headers for Lambda HTTP responses.

Getting Started

To get started with this project, clone the repository and install the necessary dependencies.

Usage

const cors = require("cors-for-lambda");

exports.handler = async (event) => {
  const response = {
    statusCode: 200,
    body: JSON.stringify("Hello from Lambda!"),
  };
  return cors.corsResponse(response, "*");
};

for multiples sites:

const cors = require("cors-for-lambda");

exports.handler = async (event) => {
  const response = {
    statusCode: 200,
    body: JSON.stringify("Hello from Lambda!"),
  };
  return cors.corsResponse(
    response,
    "https://example.com",
    "https://example2.com"
  );
};

Or

const { responseHeader } = require("cors-for-lambda");

exports.handler = async (event) => {
  const response = {
    statusCode: 200,
    headers: responseHeader("https://example.com", "https://example2.com"),
    body: JSON.stringify("Hello from Lambda!"),
  };
  return response;
};

Contributing

Contributions are welcome. Please feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License.

FAQs

Package last updated on 01 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts