1.0.0-rc.37 • Published 3 months ago

@exobase/use-cors v1.0.0-rc.37

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

title: 'useCors' description: 'A hook to automatically add CORS headers'

group: 'Hooks'

An Exobase hook that automatically responds to OPTIONS requests with standard CORS headers. Also allows you to extends and override the headers with your own values as needed.

Install

yarn add @exobase/use-cors
# or
yarn add @exobase/hooks

Import

import { useCors } from '@exobase/use-cors'
// or
import { useCors } from '@exobase/hooks'

Usage

Add the useCors hook anywhere before your endpoint. When an OPTIONS request is handled the useCors hook will resopnd with the configured (or default) CORS headers and will not call your endpoint function.

import { compose } from 'radash'
import type { Props } from '@exobase/core'
import { useExpress } from '@exobaes/use-express'
import { useCors } from '@exobase/use-cors'

// Not called when request.method = 'OPTIONS'
const endpoint = (props: Props) => {
  return {
    message: 'success'
  }
}

export default compose(useExpress(), useCors(), endpoint)
1.0.0-rc.37

3 months ago

1.0.0-rc.36

3 months ago

1.0.0-rc.35

3 months ago

1.0.0-rc.34

3 months ago

1.0.0-rc.32

9 months ago

1.0.0-rc.28

1 year ago

1.0.0-rc.27

1 year ago

1.0.0-rc.26

1 year ago

1.0.0-rc.25

1 year ago

1.0.0-rc.29

1 year ago

1.0.0-rc.31

1 year ago

1.0.0-rc.30

1 year ago

1.0.0-rc.24

1 year ago

1.0.0-rc.23

1 year ago

1.0.0-rc.22

1 year ago

1.0.0-rc.20

1 year ago

1.0.0-rc.21

1 year ago

1.0.0-rc.17

1 year ago

1.0.0-rc.16

1 year ago

1.0.0-rc.15

1 year ago

1.0.0-rc.14

1 year ago

1.0.0-rc.19

1 year ago

1.0.0-rc.18

1 year ago

1.0.0-rc.13

1 year ago

1.0.0-rc.12

1 year ago

1.0.0-rc.11

1 year ago

1.0.0-rc.10

1 year ago

1.0.0-rc.9

1 year ago

1.0.0-rc.8

1 year ago

1.0.0-rc.7

1 year ago

1.0.0-rc.6

2 years ago

1.0.0-rc.5

2 years ago

1.0.0-rc.4

2 years ago

1.0.0-rc.3

2 years ago

1.0.0-rc.2

2 years ago