woutercouvaras
woutercouvaras
NNuxt
Created by woutercouvaras on 4/18/2024 in #❓・help
Dynamic hostname / Nitro
Hi, I've got a single nuxt 3 app that serves two websites. The sites are backed by Sanity. When a request comes in, I grab the domain from event?.node?.req?.headers?.host in my default layout, and ased on the domain, I'm able to set various bits of config, which all works great. I've just enabled the @nuxtjs/sitemap module and got everything working nicely when I hardcode a hostname. When I try to read it from the rquest, it just shows as localhost (in nitro). Normally, one would simply set your appUrl or baseUrl in your nuxt.config, but because this app serves two different domains I can't do that. I've tried everything I can think of - I've even tried using getRequestHost from h3, but I always get localhost. I can get the correct host in a nitro plugin and tried to set a custom header (and various other properties), but they always get overriden to localhost. I've even tried to figure out if there's a way to dynamically inject something into runtimeConfig, but the only way I can find to do that is via .env which won't work in this case. Is there anyone that does something similar or could shed some light, I'd be deeply grateful! Thanks!
3 replies
NNuxt
Created by woutercouvaras on 3/8/2023 in #❓・help
Re-usable server/api code
Hi, Is there any best practice or guide to creating reusable api code in nuxt3? I've got some code that needs to stay private (hence using the server), but I'd like to make some of it reusable in my api endpoints/functions.
3 replies
NNuxt
Created by woutercouvaras on 2/20/2023 in #❓・help
Nuxt Layers
I'm so excited for nuxt layers! I think it's a fantastic feature, so thanks to all that have worked on it! I've just started working with layers and used the starter theme project to setup a layer and added a few modules (tailwind etc) and it all seems to be working nicely. I include the layer into another project and tailwind and my components are all there and seem to work. The only thing that's not working is that any components from the layer that contain tailwind classes remain unstyled in the project the layer is imported to. These are standard tailwind classes that work if I use them elsewhere in the project, but the classes on these imported components do not work. It seems like some sort of scoping issue, but I can't figure it out. I've looked at https://github.com/Atinux/content-wind-template and content-wind projects to see if I can figure it out and it all JustWorks(™)... I started with a private npm layer (hosted on github), but I'm now working on a basic, local layer to keep things simple (still experiencing the same). Has anyone had any experience with layers that might be able to shed some light?
14 replies
NNuxt
Created by woutercouvaras on 1/20/2023 in #❓・help
runtime lint
I've got a new Nuxt3 app up and running, using typescript. I've setup eslint and all seems to be working except that I can't get the runtime lint to work. Has anyone managed to get it working? I've added added this to my nuxt.config.ts file and I've even tried to install the fork-ts-checker-webpack-plugin dependancy, but seeing as its a webpack plugin, I didn't expect it to make any difference (which it doesn't) 😦 https://typescript.nuxtjs.org/guide/lint/#runtime-lint
1 replies