manbartz
manbartz
NNuxt
Created by manbartz on 11/27/2024 in #❓・help
UBadge leading and trailing slots don't work
Using code copied directly from the docs and the leading and trailing slots aren't doing anything. What could I be missing? Here's a repro: https://stackblitz.com/edit/nuxt-ui-uwexr7?file=app.vue
5 replies
NNuxt
Created by manbartz on 6/15/2024 in #❓・help
getCookie in server routes returns undefined on initial page serve (ssr)
Hi there, Experiencing an issue where cookies are unavailable in H3 events inside /server/api/ route requests on initial page serve (ssr). For example, say I'm fetching some data on a page component:
<script setup>
const country = await $fetch('/api/country', {
method: 'get'
});
</script>
<script setup>
const country = await $fetch('/api/country', {
method: 'get'
});
</script>
Inside ~/server/api/country.get.ts, I'm getting a cookie like this: const countryCode = getCookie(event, 'country'); Everything works as expected when navigating to the page via NuxtLink or navigateTo, but when reloading the page, the cookie is undefined (and throws an error). Here's a repro: https://stackblitz.com/edit/github-bbkvhs?file=server%2Fapi%2Fcountry.get.ts How to reproduce the issue: -Select a country (which sets a cookie) -Click "View Country" -You'll see that the country data is fetched and works as intended -Now refresh the page, you should get an error [GET] "/api/country": 500 Country cookie not found! Any ideas why this is happening? Also, I realize my very simple example isn't the best way to handle a flow like this, but in my actual use case I need to get an access token from a cookie to make an authenticated request to my database, and for whatever reason I'm not able to do this on initial page serve.
8 replies