Strange behavior when submitting post request in Angular 2

前端 未结 3 1854
春和景丽
春和景丽 2020-12-19 21:36

I realize my title is a bit vague, but here is my situation. I have just started an application in which I am implementing JWT for authentication. I have my server side se

3条回答
  •  被撕碎了的回忆
    2020-12-19 22:27

    It looks like you're having problems with a cross origin request.
    The page host (localhost:4200) is different than the destination (localhost:5000).

    When that happens chrome issues a preflighted request:

    Unlike simple requests (discussed above), "preflighted" requests first send an HTTP request by the OPTIONS method to the resource on the other domain, in order to determine whether the actual request is safe to send. Cross-site requests are preflighted like this since they may have implications to user data.

    The response you get from there server doesn't include the needed CORS headers, and therefor chrome doesn't issue the actual POST request.

提交回复
热议问题