1.1.1 • Published 6 months ago

@caviajs/http-cors v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Introduction

Cross-Origin Resource Sharing is a mechanism that allows resources to be requested from another domain.

Usage

Installation

npm install @caviajs/http-cors --save

Configure the interceptor

Config builder

import { HttpCors } from '@caviajs/http-cors';
import { Interceptor } from '@caviajs/http-router';

export const CorsInterceptor: Interceptor = HttpCors.setup(request => {
  return {
    /*
      'Access-Control-Allow-Credentials'?: boolean;
      'Access-Control-Allow-Headers'?: string[];
      'Access-Control-Allow-Methods'?: ('DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT')[];
      'Access-Control-Allow-Origin'?: string;
      'Access-Control-Expose-Headers'?: string[];
      'Access-Control-Max-Age'?: number;
    */
  };
});

Config object

import { HttpCors } from '@caviajs/http-cors';
import { Interceptor } from '@caviajs/http-router';

export const CorsInterceptor: Interceptor = HttpCors.setup({
  /*
    'Access-Control-Allow-Credentials'?: boolean;
    'Access-Control-Allow-Headers'?: string[];
    'Access-Control-Allow-Methods'?: ('DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT')[];
    'Access-Control-Allow-Origin'?: string;
    'Access-Control-Expose-Headers'?: string[];
    'Access-Control-Max-Age'?: number;
  */
});

Bind the interceptor

httpRouter
  .intercept(CorsInterceptor);
1.1.1

6 months ago

1.1.0

10 months ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago