question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot connect to Strapi, Status code 403

See original GitHub issue

Node.js version: node v12.1.0 npm version: npm 6.9.0 Strapi version: strapi 3.0.0-beta 11 Operating system:

mac Which example is causing problem? https://blog.strapi.io/building-a-static-website-using-gatsby-and-strapi/#allowaccess

Do you want to request a feature or report a bug? bug What is the current behavior? Graphql Query doesn’t work.

If the current behavior is a bug, please provide the steps to reproduce the problem

yarn start
..
success copy gatsby files - 0.058 s
success onPreBootstrap - 0.010 s
Authenticate Strapi user
Authenticate Strapi user: 501.412ms
Starting to fetch data from Strapi (articles)
Starting to fetch data from Strapi (users)
(node:33533) Warning: Label 'Fetch Strapi data' already exists for console.time()

 ERROR #11321  PLUGIN

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

Request failed with status code 403



  **Error: Request failed with status code 403**
  
  - createError.js:16 createError
    [karma-client]/[axios]/lib/core/createError.js:16:15
  
  - settle.js:18 settle
    [karma-client]/[axios]/lib/core/settle.js:18:12
  
  - http.js:202 IncomingMessage.handleStreamEnd
    [karma-client]/[axios]/lib/adapters/http.js:202:11
  
  - task_queues.js:84 processTicksAndRejections
    internal/process/task_queues.js:84:17
  

warn The gatsby-source-strapi plugin has generated no Gatsby nodes. Do you need it?
success source and transform nodes - 0.878 s
success building schema - 0.252 s
success createPages - 0.002 s
success createPagesStatefully - 0.045 s
success onPreExtractQueries - 0.004 s
success update schema - 0.025 s
success extract queries from components - 0.286 s
success write out requires - 0.005 s

What is the expected behavior?

I can fetch articles from strapi playground http://localhost:1337/graphql

Doesn’t work when I try to get from gatsby http://localhost:8000/___graphql

There is no method allStrapiArticle. I think the connection from client to server is not working. Tried authenticated, unauthenticated all possible options

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

19reactions
msmaromicommented, Jul 25, 2019

Make sure articles & users has public permissions

3reactions
nobisrocommented, May 23, 2022

For me, this was caused by using a Read-only API token. Using a full-access token fixed the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Strapi API giving 403 Forbidden Error
I have added a new collection type in strapi and when I try getting data API is giving a 403 error. We need...
Read more >
Authenticated Requests to Strapi - Codemancers
As collections are restricted by default, it cannot be accessed as a Public user resulting in 403 status code. To get rid of...
Read more >
Responses | Strapi Documentation
Get response status. By default, response.status is set to 404 unlike node's res.statusCode which defaults to 200 .
Read more >
gatsby-source-strapi
Make sure to create a full-access API token in Strapi. Path: ./.env.development. STRAPI_API_URL=http://localhost:1337 STRAPI_TOKEN= ...
Read more >
Strapi Internals: Customizing the Backend [Part 1 — Models ...
As you can see, we're getting a 403 forbidden error. That's because Strapi doesn't return anything for unauthenticated routes by default. We need...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found