Options
All
  • Public
  • Public/Protected
  • All
Menu

Handler that sets CORS options on the response. In case of an OPTIONS request this handler will close the connection after adding its headers.

Solid, ยง7.1: "A data pod MUST implement the CORS protocol [FETCH] such that, to the extent possible, the browser allows Solid apps to send any request and combination of request headers to the data pod, and the Solid app can read any response and response headers received from the data pod." Full details: https://solid.github.io/specification/protocol#cors-server

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

  • new CorsHandler(options?: SimpleCorsOptions): CorsHandler

Properties

Private Readonly corsHandler

corsHandler: (req: CorsRequest, res: { end: () => any; setHeader: (key: string, value: string) => any; statusCode?: number }, next: (err?: any) => any) => void

Type declaration

    • (req: CorsRequest, res: { end: () => any; setHeader: (key: string, value: string) => any; statusCode?: number }, next: (err?: any) => any): void
    • Parameters

      • req: CorsRequest
      • res: { end: () => any; setHeader: (key: string, value: string) => any; statusCode?: number }
        • end: () => any
            • (): any
            • Returns any

        • setHeader: (key: string, value: string) => any
            • (key: string, value: string): any
            • Parameters

              • key: string
              • value: string

              Returns any

        • Optional statusCode?: number
      • next: (err?: any) => any
          • (err?: any): any
          • Parameters

            • Optional err: any

            Returns any

      Returns void

Methods

canHandle

  • Checks if the input data can be handled by this class. Throws an error if it can't handle the data.

    Parameters

    Returns Promise<void>

    A promise resolving if the input can be handled, rejecting with an Error if not.

handle

handleSafe

  • Helper function that first runs the canHandle function followed by the handle function. Throws the error of the canHandle function if the data can't be handled, or returns the result of the handle function otherwise.

    Parameters

    Returns Promise<void>

    A promise resolving if the input can be handled, rejecting with an Error if not. Return value depends on the given type.