Hendrik Jan
Auto-import of /utils not working in VS-Code in template block
Even though my application builds and works fine, the auto-import of my function
t()
doesn't get recognized inside the <template>
.
The function is defined like this:
Inside the <script setup lang="ts">
block the auto-import works,
but in the <template>
block it doesn't.
If I add import { t } from '~/utils/translate.ts'
to the script it starts working in the template, but that would
defy the usefullness of auto-imports.
Gives me the error:
Does anyone know how to get this working?14 replies
Can you extend H3EventContext?
I'm trying to type my context correctly so it can be used inside defineEventHandler() like this:
I'm trying to extend H3EventContext like this:
However, the type H3EventContext seems not to exist anywhere (
import { H3EventHandler } from 'h3'
doesn't work).
Now, I found this issue that seems to be solved: https://github.com/unjs/h3/issues/122, but I don't understand how this works at all.
I've tried to add this to /server/graphql/context.ts:
But this does not seem to fix anything.4 replies
How can I import a markdown file from /assets?
I've got a markdown file named "CHANGELOG.md" in my /assets folder that I want to import using typescript.
* I added
declare module "*.md";
to global.d.ts
so Typescript will accept it in imports.
* I've added import changelog from '~/assets/CHANGELOG.md';
to my file /pages/changelog.vue
.
* I've added vite: { assetsInclude: ['**/*.md'] }
to my nuxt.config.js
.
This gives me the following error: Loading module from “https://tapp.docker.dev/_nuxt/assets/CHANGELOG.md?import” was blocked because of a disallowed MIME type (“text/html”)
I also tried to get this working using CodeSandbox or Stackblitz, but they fail already when I add the change to nuxt.config.js
: https://stackblitz.com/edit/github-zjjjbk?file=nuxt.config.ts
How can I use .md
files from my assets folder?1 replies
What path to use, to read a file from public folder?
The "dev" public folder is in another location than the "build" public folder.
Using filesystem tools, how can you access these files in a way that works both in "dev" and in "prod"?
I currently use this:
In
nuxt.config.js
we use the legacy "static" folder instead of "public" for historical reasons:
This does work, but it feels like a hack.
Is there a clean way to generate a file path to the public folder that works both in "dev" and in "build"?1 replies
Way to catch errors in all composables?
Hi people,
Is there a way to catch errors in any of your composables (client side)?
I know that I can use
<NuxtErrorBoundary>
to catch errors in any component, but this does not catch errors in a composable.
I also tried nuxtApp.hook('vue:error', ...
in a plugin, which does catch some errors, but not in composables.1 replies
Getting error "Component is already mounted" when using "useFetch()" and changing route.
I am getting the error in my console:
This is when using multiple
useFetch()
in a composable and then navigating to another route.
A reproduction can be found here: https://stackblitz.com/edit/github-o9ivmk-bcdf3h?file=layouts%2Fdefault.vue
I'm quite sure it has to do with the composable useTwoStepFetch()
but unsure how to solve.
I cannot change useFetch()
to $fetch
, because I want the call to be deduped.
Any ideas?1 replies
Can you use useFetch twice in one composable, once on server, once in client?
I am trying to use
useFetch()
once on the server and a second time in the client, in one composable.
So far I have not been able to get this to work.
A reproduction of my attempt can be found here: https://stackblitz.com/edit/github-o9ivmk?file=composables%2FuseTwoStepFetch.ts
It is the second useFetch()
with server:false
that I cannot get to return something -- it always returns null
.
Is there a way to get this working? An example somewhere?
The composable looks like this:
15 replies
Using Nuxt3 behind Apache proxy?
Hi, has anyone experience on getting Nuxt to work behind an Apache proxy?
I've tried anything I can think of but HMR keeps giving errors in my console.
Part of my Virtualhost definition looks like this:
And to handle wss on with Nuxt I have this in nuxt.config:
Apache responds with:
https: attempt to connect to 172.19.0.9:24678 (tapp_nodejs.docker.dev:24678) failed
8 replies