Skip to main content

My APIs using JavaScript fetch()



  • Chris Coppenbarger

    I just tried it from a ngrok url, and it's also returning an "unauthorized" response.

  • Scott Henderson CTO
    Answer Pro
    Top Contributor

    Invoking APIs directly from a browser is currently unsupported (due to CORS).  This is a known enhancement request, but it is not trivial to expose this capability securely (i.e. where API tokens in the browser layer need to be secured, else limited in scope, etc...).

    The only way to work around the CORS issue right now is to call the API directly from your backend servers.  This is not always possible of course, but hopefully this guidance can unblock you.

  • Chris Coppenbarger

    Thanks Scott. I figured this was the case, since I have the same issue with Shopify and accessing their Admin API via the same Vue app. I'll see what I can do to make it work from a "backend" server. I'll probably just add a route via my Koa server I'm using to serve up the app in Shopify.


Please sign in to leave a comment.