πŸ’Ύ
Storing Data
A common pattern in SaaS apps is to give each customer a unique subdomain. By default second-level domains are considered internal to your application. (For more info see Defining Internal URLs below)
Say you have your customers login at https://login.yourapp.com which then redirects them to https://yourcustomer.yourapp.com. You can store the last used subdomain and redirect your users there when they open the app.
1
// On login to subdomain https://yourcustomer.yourapp.com
2
if (windows.todesktop) {
3
localStorage.setItem('subdomain', 'yourcustomer');
4
}
5
​
6
// When not already on subdomain then redirect to last used subdomain
7
if (window.todesktop) {
8
const subdomain = localStorage.getItem('subdomain')
9
​
10
if (subdomain) {
11
window.location = `https://${subdomain}.yourapp.com`
12
}
13
}
Copied!
We recommend having a separate javascript app for all of your ToDesktop specific login and importing that conditionally when your app is running as a desktop app.
​
Last modified 2yr ago
Copy link