Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.

Options requests return 405 status #15

@ubudubu

Description

@ubudubu

In blazor client app I want to make call to external API based on ntrada. I want to send DELETE request but httpClient sends preflight OPTIONS request. In response from API I get:

HTTP/1.1 405 Method Not Allowed
Connection: close
Date: Sun, 22 Mar 2020 10:00:31 GMT
Server: Kestrel
Content-Length: 0
Allow: DELETE

httpClient exception:

Access to fetch at 'http://localhost:5000/smth/e928eade-cd49-4bfa-b36a-5b0a7839b279' from origin 'https://localhost:4999' has been blocked by CORS policy: Method DELETE is not allowed by Access-Control-Allow-Methods in preflight response.

Shouldn't status code 200 be returned in this case?

My route config is:

      - upstream: /{id}
        method: DELETE
        use: downstream
        downstream: smth-service/smth/{id}?userId=@user_id
        auth: true
        bind:
          - userId:@user_id  

I tried to allow OPTIONS methods in that way:

      - upstream: /{id}
        methods:
            - DELETE
            - OPTIONS
        use: downstream
        downstream: smth-service/smth/{id}?userId=@user_id
        auth: true
        bind:
          - userId:@user_id  

but it occurred in exception:

System.Collections.Generic.KeyNotFoundException: 'The given key 'options' was not present in the dictionary.'

I also tried set forwardStatusCode to false but even then I got 405 instead of 200.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions