Subdomain and custom domain - Part 2
Hi there, In the last newsletter, I talked about how I deal with subdomain and custom domain.
Here is an update. Carter who is working on Approximated reached out to me, saying he’s working on the latency issue. It’s his top priority at the moment. So, it’s going to be fine, right?
However, even if so, I have a different problem. The way I dealt with multi-domain was based on Lee Robinson‘s Next.js Multiple Domains. It uses getServerSideProps
to differentiate domains and lets me provide different content accordingly. It’s okay, but it was slower than I expected. I wished I could provide statically generated content, especially with Incremental Static Regeneration. It can become really fast.
How can I do that? I spent lots of time thinking. I think I even thought about it in my sleep. And surprisingly I came up with an easy solution. Once user creates a project on Quill, my server will create a project on Vercel, deploy the app, and configure the subdomain to the app. So, basically my Vercel account will have as many apps as Quill users create projects. Each app will point to a something.quill.so
subdomain and a custom domain if configured.
Okay, then how can I create and deploy an app on Vercel via API? Unfortunately I cannot deploy from my GitHub repository because of this:
Vercel Projects Connected per Git Repository (Limits)
- Hobby: 3
- Pro: 10
- Enterprise: Custom
A workaround for this is to deploy via Vercel CLI but on CircleCI. I create a workflow there and call the API of CircleCI and it will create and deploy an app on Vercel. And I can check the status of the job via CircleCI’s API, which will be displayed to users.
Yes, that’s a long journey. I didn’t want to make it too complicated from the beginning. I worried if I was over-engineering. However, the limitation of the previous implementation was too obvious and I didn’t want to compromise the basic performance.
Now the basic flow is done. So the next step is to implement payment. I’m going to use Paddle. Let’s see how it goes. Thanks for reading!
Update @ 22 Jul 2021: Approximated now has global clustering, so you’ll no longer lose the benefits of Vercel’s edge network if you choose multiple regions.