Skip to content

CORS headers #128

@thekid

Description

@thekid

Example allowing direct connections from any host with any headers

$cors= new class() implements Filter {
  public function filter($request, $response, $invokation) {
    $response->header('Access-Control-Allow-Origin', '*');
    $response->header('Access-Control-Allow-Headers', '*');
    if ('OPTIONS' === $request->method()) {
      $response->answer(200);
      return;
    }
    return $invokation->proceed($request, $response);
  }
};

Should there be an implementation for this in web.filters?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions