Markeem
Markeem
NNuxt
Created by Markeem on 7/20/2024 in #❓・help
Adding cookies on ssr response
I recently had a use case for setting cookies on the server side. As far as I understood it: If we fetch (e.g. with useFetch) from an internal api during ssr, the cookies etc. wont be forwarded due to an internal function call instead of a fetch call for performance reasons. But the client headers have to exist on the initial request to the nuxt backend, right ? Why can't they be forwarded internally with the function call ? Is there some kind of security risk ? It got even more complicated when trying to set-cookies in the ssr response: https://nuxt.com/docs/getting-started/data-fetching#pass-cookies-from-server-side-api-calls-on-ssr-response Cant this be simplified ?
1 replies
NNuxt
Created by Markeem on 2/22/2024 in #❓・help
Styles not inlined as expected with SSR enabled
Hey! I am using the tailwind module for my app and noticed that only the fonts I declared in assets/css/main.css (imported through nuxt config) are placed in a a style tag in the head element. All the Tailwind styles are in a Stylesheet (Link element) even though they are definitely needed right away. I need the styles to be present inline for my use case. Does anyone have an Idea what could cause this behaviour and how I could force the styles to be inlined ?
1 replies
NNuxt
Created by Markeem on 6/14/2023 in #❓・help
Wrapping $fetch in composable with default options while retaining type safety
I managed to get autocomplete for the routes, but the return type is unknown. How can I get the return type working ? Example:
import type { NitroFetchRequest } from 'nitropack'

export function useFetchWithDefaultOptions(url: NitroFetchRequest) {
return $fetch(url, {
headers: {
defaultHeader: 'value',
},
})
}
import type { NitroFetchRequest } from 'nitropack'

export function useFetchWithDefaultOptions(url: NitroFetchRequest) {
return $fetch(url, {
headers: {
defaultHeader: 'value',
},
})
}
2 replies
NNuxt
Created by Markeem on 11/20/2022 in #❓・help
How to return blob (application-pdf) from api route
Hey I am using the Browserless.io api to generate pdf files, which returns a Blob (application/pdf). When I return the blob as is, i only get a proxy object on the client side with nothing in it. It works when using: Buffer.from(await data.text()).toString('base64') Is this the right way to do it ?
1 replies