#Guides for redirect to app.site.com

41 messages · Page 1 of 1 (latest)

white stratus
#

How should I approach this requirement where I have my site at site.com. And I would like for the main application to live at app.site.com. How should I approach this?

woven shadowBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

simple quartz
#

Easiest solution is to use vercel nameservers, and add that domain to vercel i.e. app.site.com

#

vercel will handle the rest

last linden
acoustic crag
last linden
#

well, we never know when OP is not answering ^^

acoustic crag
#

Thats true lol

last linden
#

Wow the third person that said that 😂

white stratus
#

Sorry, guys! Was night time in my time zone

#

I’m thinking of apps like Tinybird or WorkOS where their site.com is used for landing/marketing. And when you’re signed it, you’re redirected to app.site.com

simple quartz
#

I'll explain steps in detail if you want

white stratus
#

I still want to use site.com for things like /pricing, /about, /contact, for example. However, for paths like /signin, /signup, /slug/dashboard I want them to be at app.site.com

simple quartz
#

thats a simple way

white stratus
#

Ahhhhh. Yes, yes. That does make sense

#

For the sake of knowledge haha, how would you approach the “difficult” way if you were to do this with one app

simple quartz
#

for 1 nextjs app

#

wait not wildcard

#

You have to create 2 domains, pointing to same app

#

add 2 domains*

#

And in nextjs app only, you'll have to redirect from app.com to app.site.com/signin, it'll be in the same app. However, if you want it such that app.com/signin doesn't work, you might need to use a condition for that, or middlewares.

#

Also, mark my message as a solution

#

its not actually difficult, but time-consuming

white stratus
#

How would I test this out in localhost?

#

If at all possible

simple quartz
simple quartz
#

in .env, set up both the urls, including values for condition

#

window.location.host, to see the host

#

here is a example condition(Could be inefficient and could have errors)

const pagesInSubdomain = ["/login"] 
//sign in page
if(pagesInSubdomain.includes(window.location.pathName) && window.location.host !== process.env.SUBDOMAIN_URI)  {
redirect(process.env.SUBDOMAIN_URI + window.location.pathName)
}
#

it just gives you a idea on how to achieve this

white stratus
#

Ahhhh. Okay, okay. Thanks a bunch!!