New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@sctg/nocors

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
Package was removed
Sorry, it seems this package was removed from the registry

@sctg/nocors

Minimalist noCors proxy for servless app

latest
Source
npmnpm
Version
0.9.9
Version published
Maintainers
1
Created
Source

Simplest noCors proxy for Serverless(Azure/Cloudflare) Web App

This is a very minimalistic proxy for enabling CORS on non CORS enabled sites.

For Azure Static Web Apps

Create a new api entry with VSCode Azure tools or manually.

npm i --save @sctg/nocors
cd api
npm i --save got
npm i --save @azure/functions

In the index.ts of the new api route

import {
  AzureFunction,
  Context,
  HttpRequest,
} from "@azure/functions";
import { proxyAzureRequest } from "@sctg/nocors/Azure/index.js";
const WHITELIST_REGEX=".*"

const httpTrigger: AzureFunction = async function (
  context: Context,
  req: HttpRequest
): Promise<void> {
  const proxiedRequest = await proxyAzureRequest(WHITELIST_REGEX, req);
  context.res = {
    status: proxiedRequest.status,
    body: proxiedRequest.body,
    headers: proxiedRequest.headers,
  };
};

export default httpTrigger;

For Coudflare Pages

npm i --save @sctg/nocors
npm i -D --save @cloudflare/workers-types

create a /functions/proxy.ts file

import {proxyRequest} from "@sctg/nocors/Pages"
const WHITELIST_REGEX=".*"
export const onRequest: PagesFunction = async (context) => {
  return proxyRequest(context,WHITELIST_REGEX)
};

Keywords

cors

FAQs

Package last updated on 14 Nov 2022

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