-
Notifications
You must be signed in to change notification settings - Fork 539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support canonical URL #2052
Comments
How would you utilize this if the canonical URL is determined at runtime, such as in a multi-tenant environment with dynamic subdomains? |
|
Since we only build once, setting an env variable isn't an option
I've tried this, but even when setting the
There doesn't seem to be a consistent way |
You set environment variables when running instance. It is possible to set them after-build actually, hence the benefit of using of runtimeconfig.
would be worth to track with another issue if you don't mind to make a minimal reproduction of your setup so i can investigate 🙏🏼 |
Have a simple of example of how you would set the runtimeConfig value after build, e.g. when the app first initializes and grab the browser's hostname, etc.?
Here's a new issue with reproduction and a deployed preview: #2388 |
I would also like to chime in here, I've been spending the better half of 2 days now trying to work around this problem. What we do:
What works: What doesn't work: So far, I have been able to get caddy to forward the correct headers and have added the described nuxt config:
I have also added logging to trace what is actually happening using:
This is what the logs show: main domain (foldera):
sub domain(folderb):
At this point, I am wondering what I could do and given @adamdehaven worked on this I was wondering if you managed to make it work or if more work is required in Nitro / Nuxt. Small update I managed to debug my way to the following error: Update It all boils down to the following, the node req url property with the main domain is
2024-09-09 - Update Based on another change suggested for H3 about sanitizing the URL (unjs/h3#765) I forked the repo and made my own change to fix this and resolve it: nschipperbrainsmith/h3-tentant-fix@0a7da1f This allows me to do the following in Nuxt:
|
ref nuxt/nuxt#24813
Today, we expose
useRequestURL()
utility to access the current request URL however it can be tricky in two situations:varies
(which can also lead to cache leaks)Proposal:
app.canonicalURL
in runtimeConfig for env support + app config for dynamic behavior support (prefer app)useRequestURL()
useCanonicalURL()
(suggested by @atinux) that falls back touseRequestURL()
if the user hasn't configured a canonical URL and fails for SSG if not providedThe text was updated successfully, but these errors were encountered: