How to use API token in Nuxt3
See original GitHub issueHi,
I’m not using user authentication on my app, but I’m wanting to protect my API with the API Token.
How can I put the API token into the header request?
await create<Strapi4Response<Subscriber>>("subscribers", {
email: data.email,
});
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Nuxt 3 JWT authentication using $fetch and Pinia
get JWT token and user info from API (edit: done!) and store both (to keep user logged even if a page is refresh);...
Read more >Where store user Token in my Nuxt 3 app? #10402 - GitHub
Hi, I'm using Nuxt 3 with a fullstack approach, I'm using Pinia for the store, and Prisma as ORM to interact with my...
Read more >Auth in Nuxt 3 the EASY WAY - YouTube
Check out Storyblok (especially their Nuxt 3 module): ... ( definitely use this, I went fast in the video lol) Supabase Authentication : ......
Read more >How To Add Auth To A Nuxt App in Minutes with Amplify!
Nuxt 3 + Authentication : How To Add Auth To A Nuxt App in Minutes with ... and how you can use this...
Read more >How to Implement auth0 Authentication in Nuxt3
So let's start with the Nuxt3 project. npx nuxi init nuxt-app. I am using a JavaScript library from auth0 “@auth0/auth0-spa-js”. npm i @auth0/auth0-spa-js....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @IzakJackson,
An easy solution for now could be to use the
client
directly, you can check out the documentation here https://strapi.nuxtjs.org/usage#usestrapiclient.Here is an example:
For informations, the
create
method is juste a wrapper around theclient
, you can check out the code here https://github.com/nuxt-community/strapi-module/blob/dev/src/runtime/composables/useStrapi4.ts#L43From what I see here: https://github.com/nuxt-community/strapi-module/blob/e722d34b6d4a69e1b7d34d3807b636ba82a4b452/src/runtime/composables/useStrapiClient.ts#L52
We need to update https://github.com/nuxt-community/strapi-module/blob/dev/src/runtime/composables/useStrapi4.ts#L43-L45 in order to also forward the FetchOptions.