storyblok / gatsby-storyblok-boilerplate

Gatsby starter template with Storyblok's headless cms and true preview
https://www.storyblok.com/tp/add-a-headless-cms-to-gatsby-5-minutes
BSD Zero Clause License
37 stars 28 forks source link

Request failed with status code 401 #9

Closed 2metres closed 4 years ago

2metres commented 5 years ago
 ERROR #11321  PLUGIN

"gatsby-source-storyblok" threw an error while running the sourceNodes lifecycle:

Request failed with status code 401

  Error: Request failed with status code 401

  - createError.js:16 createError
    [gatsby-storyblok-boilerplate]/[axios]/lib/core/createError.js:16:15

  - settle.js:17 settle
    [gatsby-storyblok-boilerplate]/[axios]/lib/core/settle.js:17:12

  - http.js:237 IncomingMessage.handleStreamEnd
    [gatsby-storyblok-boilerplate]/[axios]/lib/adapters/http.js:237:11

  - task_queues.js:77 processTicksAndRejections
    internal/process/task_queues.js:77:11
pedrosousa13 commented 4 years ago

did you add the correct preview token?

emanuelgsouza commented 4 years ago

Hi, @2metres is there any update about this problem?

2metres commented 4 years ago

I haven't been able to reproduce, closing the issue

kaushalyap commented 2 years ago

@emanuelgsouza I am getting this error in Cloudflare pages but not locally?

RobErskine commented 1 year ago

If anyone else runs into this and not sure what else to try, it turns out I was trying to hit the wrong region. By default Storyblok wants to hit the Europe region. If your space is set up in the United States you need to tell Storyblok that when you init the library.

// _app.js
storyblokInit({
  accessToken: 'xxx',
  use: [apiPlugin],
  components,
  apiOptions: {
    region: 'us' // this is what I was missing
  }
});

More documentation here: https://www.storyblok.com/faq/define-specific-region-storyblok-api