locked
Access API from Angular App-Preflight request -CORS RRS feed

  • Question

  • User2048898515 posted

    Hi ,

    I have a webapi which gives the data to Angular APP.

    When i run the Angular App locally, which connects the API which is hosted in server, i get the preflight request issue "Response to preflight request doesnt pass access control:".

    When i debug, i found that before making a API call, browser sends a Preflight request and then calls actual api request.

    When a preflight request made ie. Options (request Method) is not sending the custom header value which i need to validate the request in API (Middleware)

    So Middleware in API returns 401.

    In Options how i can send the custom header value

    or how i can by pass the Preflight

    https://ibb.co/ms9UWz

    Thursday, October 4, 2018 5:35 PM

All replies

  • User61956409 posted

    Hi nambir,

    Firstly, if you'd like to make CORS request(s), please enable CORS in your web API.

    the preflight request issue "Response to preflight request doesnt pass access control:".

    This SO thread discussed same issue, you can refer to it.

    When a preflight request made ie. Options (request Method) is not sending the custom header value which i need to validate the request in API (Middleware)

    Please check if a browser bug (not include user credentials) causes this issue, you can refer to this SO thread.

    With Regards,

    Fei Han

    Friday, October 5, 2018 7:17 AM