nuxt-modules / nuxt-modules/strapi

Server side request is returning 403

Open
#387 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
717
Forks
89
Avg merge
7h 3m
Merged PRs (30d)
6

Description

Version

@nuxtjs/strapi: 1.11.0
nuxt: 3.9.1

Reproduction

I am trying to fetch collection on server side. Problem is that I am still getting 403 on refresh (F5) site. Collection is allowed only for specific role. I can't make it public.
When I am switching between routes, everything works perfectly. When I check the console, Nuxt is first calling collection API and then User api.

image

Here is example how I call my API:

const { data:tournaments } = await useAsyncData("tournaments", () =>
  find<any>("tournaments", {
    populate: '*',
    filters: {
      'active': 'true'
    }
  })
);
</script>

I also tried use middleware and get user there, but user was still undefined.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported useAsyncData call and the module's server-side request and authentication flow, reproducing with Nuxt 3.9.1 and @nuxtjs/strapi 1.11.0. Compare the request ordering shown in the console during a full refresh and route navigation. Done means an authenticated user can fetch the protected collection on refresh without a 403.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript
Domain
api, authentication, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.