NightFuries
NightFuries
Explore posts from servers
NNuxt
Created by NightFuries on 1/20/2025 in #❓・help
Attach data to the inline-middleware
In a particular page route, I must make a API request to my backend. The result from the backend should carry forward to the page to access it. Is this possible?
<script setup>
const userData = ref()

definePageMeta({
middleware: [
async function(to, from) {
const { data } = await useFetch('/api/person');
userData.value = data
}
]
})
</script>
<script setup>
const userData = ref()

definePageMeta({
middleware: [
async function(to, from) {
const { data } = await useFetch('/api/person');
userData.value = data
}
]
})
</script>
18 replies
NNuxt
Created by NightFuries on 1/19/2025 in #❓・help
set API_BASE_URL in static site
My landing page project has 3 environments: dev, staging, production, and the API url for all 3 environments are different. How can my static site use an environment variable for this?
14 replies
NNuxt
Created by NightFuries on 1/15/2025 in #❓・help
Minify JS build code
I am building my nuxt app but the js is not minified, exposing the contents of all API route handlers. Is there a way to minify this?
5 replies
NNuxt
Created by NightFuries on 1/14/2025 in #❓・help
What is the alternative to passing asset urls as props?
Nuxt does not transform ~/assets/icon.svg if it is used as a prop to a component. What are the workarounds?
4 replies
NNuxt
Created by NightFuries on 1/11/2025 in #❓・help
Choose a local file if data fetching failed
I have an api that sometimes fails to deliver a successful response. In that case, I want to default to using a local json file instead. I know that useAsyncData should be "side-effects free" but idk how else to do this operation.
17 replies
NNuxt
Created by NightFuries on 1/10/2025 in #❓・help
How to use NuxtErrorBoundary properly??
I have a component with the following code:
<template>
<NuxtErrorBoundary>
<template #error="{ error }"> Error here: {{ error }} </template>
<form
class="flex flex-col gap-4 rounded-lg border border-white px-2 py-4 lg:self-center"
:state="credentials"
@submit.prevent="handleLogin">
<!-- Some code over here -->
</form>
</NuxtErrorBoundary>
</template>

<script setup lang="ts">
const handleLogin = async () => {
throw createError({
statusCode: 400,
statusMessage: 'Something is wrong.'
})
}
</script>
<template>
<NuxtErrorBoundary>
<template #error="{ error }"> Error here: {{ error }} </template>
<form
class="flex flex-col gap-4 rounded-lg border border-white px-2 py-4 lg:self-center"
:state="credentials"
@submit.prevent="handleLogin">
<!-- Some code over here -->
</form>
</NuxtErrorBoundary>
</template>

<script setup lang="ts">
const handleLogin = async () => {
throw createError({
statusCode: 400,
statusMessage: 'Something is wrong.'
})
}
</script>
But there are no UI changes here. it does not make sense.
12 replies
NNuxt
Created by NightFuries on 1/3/2025 in #❓・help
Import a list of images from public folder
the folder public/images has 9 images that I need to use in my script setup function. I don't wish to import all 9 images separately, can I import the entire folder?
14 replies
NNuxt
Created by NightFuries on 12/31/2024 in #❓・help
Disable global middleware for one page
I have a global middleware because every route uses it except for one. How to stop this?
4 replies
NNuxt
Created by NightFuries on 12/22/2024 in #❓・help
How to stop nuxt generate to crawl links
Nuxt generate will look for all <a> tags and follow their href to generate them. How to stop this?
4 replies
NNuxt
Created by NightFuries on 12/21/2024 in #❓・help
Prerendering custom routes does not work as intented..
No description
6 replies
NNuxt
Created by NightFuries on 12/20/2024 in #❓・help
Can I have SSG and SSR in the same project??
I have 2 projects to work on in a monorepo: the landing page & a website with auth and other stuff. The main website is a simple SSR application but I wish to statically generate the landing page. The problem is that they both have the same public/ folder (for fonts) and server/ folder because of the text on the landing depends on API call to my server.
11 replies
NNuxt
Created by NightFuries on 12/13/2024 in #❓・help
How do I disable Nuxt 4 from automatically extending Nuxt apps inside `layers/` directory?
How do I disable Nuxt 4 from automatically extending Nuxt apps inside layers/ directory?
6 replies
NNuxt
Created by NightFuries on 12/3/2024 in #❓・help
Why does `fetch('/api/profile')` gives "Invalid URL" when `$fetch('/api/profile')` works just fine?
No description
6 replies
HHono
Created by NightFuries on 12/3/2024 in #help
Hono's Client does not work in Nuxt SSR
No description
2 replies
HHono
Created by NightFuries on 9/5/2024 in #help
How to keep SSE alive with PSQL?
No description
3 replies