JuanP Barba
JuanP Barba
NNuxt
Created by JuanP Barba on 5/9/2024 in #❓・help
Extending nitro node-server preset/entry
The problem was that Rollup was excluding the import because the imported code wasn't being used. This could be a possible solution: https://stackblitz.com/edit/unjs-nitro-starter-nig5kw?file=server%2Fentry.ts
3 replies
NNuxt
Created by DAQEM on 4/22/2024 in #❓・help
SSR issue
If you need to execute some code only at server, I would suggest to do it in a plugin using .server notation.
9 replies
NNuxt
Created by konsav on 4/22/2024 in #❓・help
middleware/redirect.global.js
Yes, it could be the origin of the mentioned error.
16 replies
NNuxt
Created by konsav on 4/22/2024 in #❓・help
middleware/redirect.global.js
When you say that the log is executed twice, do you mean at server log or once at server and once at client?
16 replies
NNuxt
Created by DAQEM on 4/22/2024 in #❓・help
SSR issue
My advice when working with authentication would be to avoid server-side rendering (SSR) as much as possible, to reduce the complexity that authentication already involves.
9 replies
NNuxt
Created by DAQEM on 4/22/2024 in #❓・help
SSR issue
Executing this only at SSR will break on client side if you introduce a new layout
9 replies
NNuxt
Created by DAQEM on 4/22/2024 in #❓・help
SSR issue
Oh! It helps a lot! I see that you are executing this from the layout… First of all, the code in the tag should always be running on both sides. It’s strange that it’s only running in one place or another pending on the environment.
9 replies
NNuxt
Created by DAQEM on 4/22/2024 in #❓・help
SSR issue
What do you mean with “the script”? Do you mean to all the <script> tag?
9 replies
NNuxt
Created by konsav on 4/22/2024 in #❓・help
middleware/redirect.global.js
How or where are you implementing the API endpoint? If it is internal it should be implemented at /server/api folder
16 replies
NNuxt
Created by konsav on 4/22/2024 in #❓・help
middleware/redirect.global.js
Ok, I guess the problem is what I described. If you debug the middleware you should see that it is executed twice, one for the original call and other for the endpoint call
16 replies
NNuxt
Created by konsav on 4/22/2024 in #❓・help
middleware/redirect.global.js
I didn’t see this sintax before… $../redirect/url$ Is $getApiData.fetchData executing useFetch or $fetch?
16 replies
NNuxt
Created by konsav on 4/22/2024 in #❓・help
middleware/redirect.global.js
If it is a Nuxt API endpoint, the problem is: - when you call it from the server side, it is executed internally - I think that you see two calls because the middleware is executed again when the API endpoint is called - it seems that this behaivour is sending the response before the original call and that’s why you get “Cannot set headers after they sent to client”
16 replies
NNuxt
Created by konsav on 4/22/2024 in #❓・help
middleware/redirect.global.js
The API call is to an external server or is a Nuxt API endpoint?
16 replies
NNuxt
Created by konsav on 4/22/2024 in #❓・help
middleware/redirect.global.js
Can you share an example?
16 replies
NNuxt
Created by Alexandre Nédélec on 4/22/2024 in #❓・help
Pass extra dynamic data when routing to a page
15 replies
NNuxt
Created by Alexandre Nédélec on 4/22/2024 in #❓・help
Pass extra dynamic data when routing to a page
The only thing that comes to mind is that you add the tag's slug to the keys of the posts as well... If you don't want to make this modification, I would go with route rules and SSG for /tags/{tag}. It will increase the build time, but I think all solutions for this issue (without extra key or getting tags out of posts) will ultimately involve some build script.
15 replies
NNuxt
Created by Alexandre Nédélec on 4/22/2024 in #❓・help
Pass extra dynamic data when routing to a page
I think there could be better solutions that rely on your data rather than on Nuxt itself. I mean, I'm not sure how you are getting the tags or how you are generating the /tags/{tag} page right now... Perhaps a small example of the /tags/{tag} page could help.
15 replies
NNuxt
Created by Alexandre Nédélec on 4/22/2024 in #❓・help
Pass extra dynamic data when routing to a page
Yes, using SSG the endpoint will be called only at build time
15 replies
NNuxt
Created by Gerbuuun on 4/21/2024 in #❓・help
Typescript nested generic resolves to unknown
As you are passing the infer to the method argument, you can see how the infer is ok. I would go with solution one.
7 replies
NNuxt
Created by Gerbuuun on 4/21/2024 in #❓・help
Typescript nested generic resolves to unknown
The problem at this example is with K definition. Typescript is not able to infer value of T from generic K definition. You should pass this directly to the argument: https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABFApgZygHgCoD4AUAJgIZTEBciA3omOqoZQEooRwBOhmG7MYA5gBpEeRAF8AlNQBQiROxRQQ7JCTIA6OhhSEA3NLHTpbMBmT01xRAF4ZcrQ0pVZc8xicvXyGFAA2KSgBybHpAwU9xF0NDYwQzBTQQXygbNyh8VAxLCV0gA
7 replies