Yuri
The plugin is executed twice
Hello.
I have the plugin (), which generates (or refreshes) a token. But it is executed twice: on the server and on the client. But I need the plugin start only once. If it was executed on the server, it should not be executed on the client.
But also I use SPA of this project for mobile app (Capacitor) and I can't to rename plugin to because in this case the plugin have to start on the client.
What are the appropriate options to solve my problem?
4 replies
JWT generation
Hello. I create an e-commerce project. I want to use JWT (access & refresh) for everybody (guests & users). Also I want to use
/server/api
. I create plugins/api.ts
for custom fetch.
I guess to create /server/api/token/get
& /server/api/token/refresh/
for working with tokens.
My questions:
1. Where do I need first request to token/get
for getting the token pair?
2. When the page loads I need to check "Does the cookie refreshToken
exist?" If YES I need to fetch /token/refresh/
. Where do I need to do it?
Maybe is there some ready solution?6 replies
mountSuspended & useCookie
Hello. Why my test show incorrect value for cookie?
Log:
Mock useCookie with value 0
Mock useCookie with value 1
locationConfirmationIsHidden (there isn't cookie): 1
locationConfirmationIsHidden (there is cookie): 1
Part of my component:
My test:
5 replies
eslint ignore
My esling.config.mjs:
But when I start task lint I receive such error:
C:\work\shop**android**\app\build\intermediates\assets\debug\native-bridge.js
4:5 error 'nativeBridge' is assigned a value but never used no-unused-vars
How can I exclude android & ios folders from linter?
7 replies
JWT Example Project
Hello. I develop an online store with Nuxt.
I used a third part Backend API before.
Now I want to use /server/api for it. And inside /server/API/, requests are sending to the necessary services and the database. I plan to sign all requests with the JWT token and I will keep it in the cookie.
Does anyone have examples of such real projects to see how it should be set up correctly?
1 replies
Mock API
Hello! What can I use for Mock API.
Example:
It is my /server/api/contacts/
export default defineCachedEventHandler(async (_event) => {
const data = await $fetch('https://example.com/contacts');
return {
status: 'success',
data,
};
}, { maxAge: -1 });
How can I return mock data for 'https://example.com/contacts' (It is example url for back API)
1 replies