Custom subdomain and domain for my saas users
Hello guys. I am building this crm for gym owners, and i want to add this feature of each gym build their website, a simple lading page and i was thinking in implemeting something like subdomain on it so the url can be more friendly and brandable for them. Any ideas on where to find resources to go for it or any of you have done somthing similiar in wasp?
3 Replies
Hi @Stefan Vitória. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To implement custom subdomains or domains for your SaaS users in Wasp, you'll need to consider a few aspects. While Wasp doesn't have built-in functionality specifically for this purpose, you can achieve it with some additional configuration. Here are some relevant points and resources:
1. Base Directory: Wasp allows you to serve the client from a subdirectory using the
baseDir
option in the client configuration. This can be useful for setting up subdomains. You can find more information about this in the Client Config documentation (https://wasp-lang.dev/docs/project/client-config#base-directory).
2. Custom Domains: If you're deploying with Fly.io, Wasp provides instructions for setting up custom domains. This could be adapted for your users' domains. You can find details in the Wasp CLI deployment documentation (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app).
3. Multi-tenancy: Your use case sounds like it involves multi-tenancy. While Wasp doesn't have built-in multi-tenancy features, you can implement it at the application level. There's a discussion about this in a Discord thread about multi-tenancy with Wasp and Postgres (https://discord.com/channels/686873244791210014/1206012263287226469).
4. Landing Page: For creating landing pages for each gym, you might want to consider using a static site generator alongside Wasp. Some Wasp users have mentioned using Astro for landing pages, as discussed in a Discord thread about SEO and SSR (https://discord.com/channels/686873244791210014/1219684155072184440).
To implement this feature, you'll likely need to:
1. Set up a wildcard DNS record for your main domain to handle subdomains.
2. Implement logic in your server to recognize and route requests based on the subdomain.
3. Use the baseDir
option in Wasp to serve each gym's content from the appropriate subdirectory.
4. Implement a system for gym owners to create and manage their landing pages.
Keep in mind that this is a complex feature that goes beyond Wasp's core functionality. You may need to implement custom server-side logic and potentially use additional services or tools alongside Wasp to fully realize this feature.
For more specific guidance, you might want to reach out to the Wasp community on Discord or GitHub for advice from developers who have implemented similar features.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Stefan Vitória, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?This is a pretty advanced thing to do and might require custom reverse proxy setup (I haven't done this, I'm just guessing on how I would do it).
For each subdomain, you serve the same app, but then the app loads a different config based on
window.location
or smth like that.yeah, i have never done this before as well. Just trying to see if someone here could point me in the right direction. Trying to save some time here on research