please wait

  • Gaurav Kalyani Dec-14-2018 05:21:08 AM ( 5 months ago )

    I am creating a PWA(Progressive Web Application) using react js.I am calling a login api from on http://localhost:3000.It is throwing the following error-


    " No 'Access-Control-Allow-Origin' header is present on requested resource. Origin 'http://localhost:3000' is therefore not allowed access.".


    Please help me out it stuck to me.

  • Shivang Tomar Dec-14-2018 07:00:13 AM ( 5 months ago )

    You can't access api as public on different origin, port or protocol.The api you are accessing using having secure protocol, different origin '' and you are accessing it on 'http://localhost:3000' using different protocol and origin so as per browser security rules policy you can't do so.

    To resolve this issue


    1)Go to the source where your api is running

    2)open api code and 

    3)mention the following headers in your api:

      if your api in node:

    res.header ("Access-Control-Allow-origin", "*");



    "Origin, X-Requested-With, Content-Type, Accept, Authorization"


    The above i am giving the code snipped for api written in node.

    You can set 'Access-Control-Allow-Origin' and 'Access-Control-Allow-Headers':'Origin' for your api written in any language.


Please login

Similar Discussion

Recommended For You