Rxjs: AJAX CORS Error PUT and POST

Created on 13 May 2019  路  2Comments  路  Source: ReactiveX/rxjs

Bug Report

Current Behavior
AJAX PUT and POST requests both submit a successful OPTIONS request but then throw an error Access to XMLHttpRequest at 'http://localhost:8001/issue' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. before submitting the subsequent PUT or POST request. The API has CORS configures and is working with both the GET and the Angular HTTPClient PUT and POST.

Reproduction

  • REPL or Repo link:
    (you can use https://stackblitz.com/ to create one to attach here)

I've tried with the createXHR property both set and unset.

ajax({
                        createXHR: function () {
                            return new XMLHttpRequest();
                        },
                        url: 'http://localhost:8001/issue',
                        crossDomain: true,
                        withCredentials: false,
                        method: 'PUT',
                        body: x,
                        })
                        .subscribe((result) => {
                            console.log(result);
                        })

Expected behavior
I expect for the PUT and POST requests to be submitted open successful completion of the OPTIONS request.
image

Environment

  • Runtime: [e.g. Node v${x}, Chrome v${x}]
  • RxJS version:
  • (If bug is related) Loader, build configuration: [e.g webpack, angular-cli version, config]

Possible Solution

Additional context/Screens
hots

Add any other context about the problem here. If applicable, add screenshots to help explain.

Adding screenshots for clarity:
image
image

Most helpful comment

@cartant the template wigged out and reverted back to its unedited state on submit. That's why the edit went through so quickly I'd already typed it all once before. No clue why it decided to do that.

All 2 comments

AFAICT, there is zero information provided in this issue.

Thanks. However, filling out the template before opening the issue is the usual way things are done.

@cartant the template wigged out and reverted back to its unedited state on submit. That's why the edit went through so quickly I'd already typed it all once before. No clue why it decided to do that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samherrmann picture samherrmann  路  3Comments

peterbakonyi05 picture peterbakonyi05  路  4Comments

haf picture haf  路  3Comments

LittleFox94 picture LittleFox94  路  3Comments

benlesh picture benlesh  路  3Comments