N
Nuxt6mo ago
dev1976_00

Nuxt 3 i18n set dynamic baseUrl

I have one Nuxt application. But I have many different domains (this is not related to languages). Each domain can have any language. But I have a problem with baseUrl in nuxt.config.ts. Do you have any idea how I can automatically set the domain based on the domain?
10 Replies
pyplacca
pyplacca6mo ago
Depending on where you deployed your application, the platform will add some env variables you can rely on. Netlify for instance provides a URL env variable, and DO allows you to map {{APP_URL}} to your preferred env key So for Netlify, your domain will be accessible at process.env.URL
dev1976_00
dev1976_006mo ago
I build and deployed only one time. Then I have a lot of different domains, and they follow to one site .env will be work only for build, but I need to set it dynamically
pyplacca
pyplacca6mo ago
does that mean you upload the build folder to your deployment platform?
dev1976_00
dev1976_006mo ago
Yes, I run build project, then upload to server on nginx. And few different domains follow to one launched project
pyplacca
pyplacca6mo ago
Hmm. I don’t think I have a solution I can suggest
JuanP Barba
JuanP Barba6mo ago
@dev1976_00 are you talking about nuxt.config baseURL or about i18n routing baseURL?
JuanP Barba
JuanP Barba6mo ago
JuanP Barba
JuanP Barba6mo ago
Nuxt
Nuxt Configuration
Discover all the options you can use in your nuxt.config.ts file.
JuanP Barba
JuanP Barba6mo ago
I18n allows to set a function that receives the nuxt context. I don’t know if it could work in your scenario On the other hand, I have some doubts about your approach. Why do different domains point to the same application? Do all the domains show the same information? If so, what's the goal? I hope it's not for SEO, because this actually harms the positioning… Or do they show different information based on the domain? In all cases, I believe SSR would help you configure the application adapted to each domain at runtime.
dev1976_00
dev1976_006mo ago
In depend on domain, I sent a key to all my endpoints. And yes, info could be different between domains. Yes, I have already found solution. But I need to do more tests for it
Want results from more Discord servers?
Add your server