Skip to content
This repository has been archived by the owner on Feb 5, 2023. It is now read-only.

Feature/corss domain redirect #125

Merged
merged 3 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let currentRootDomain;
const split = window.location.hostname.split('.');
if (split.length > 2) {
const isSubDomainMode = split.length > 2;
if (isSubDomainMode) {
currentRootDomain = split[split.length - 2] + '.' + split[split.length - 1];
} else {
currentRootDomain = window.location.hostname;
Expand All @@ -18,7 +19,7 @@ export default {
defaultAvatar: 'https://rss3.mypinata.cloud/ipfs/QmVFq9qimnudPcs6QkQv8ZVEsvwD3aqETHWtS5yXgdbYY5',
hideUnlistedAsstes: false,
subDomain: {
isSubDomainMode: window.location.host.split('.').length >= 3,
isSubDomainMode,
rootDomain: PAGE_ENV === 'production' ? 'rss3.bio' : currentRootDomain,
cookieExpires: 14,
},
Expand Down
9 changes: 7 additions & 2 deletions src/views/Setup/Setup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,13 @@ export default class Setup extends Vue {

async initLoad() {
if (!(await RSS3.reconnect())) {
sessionStorage.setItem('redirectFrom', this.$route.fullPath);
await this.$router.push('/');
if (config.subDomain.isSubDomainMode) {
// redirect back to root domain
window.location.host = config.subDomain.rootDomain;
} else {
sessionStorage.setItem('redirectFrom', this.$route.fullPath);
await this.$router.push('/');
}
} else {
this.rss3 = await RSS3.get();
}
Expand Down
10 changes: 8 additions & 2 deletions src/views/Setup/SetupAccounts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,14 @@ export default class SetupAccounts extends Vue {

async mounted() {
if (!(await RSS3.reconnect())) {
sessionStorage.setItem('redirectFrom', this.$route.fullPath);
await this.$router.push('/');
if (config.subDomain.isSubDomainMode) {
// redirect back to root domain
window.location.host = config.subDomain.rootDomain;
} else {
sessionStorage.setItem('redirectFrom', this.$route.fullPath);
await this.$router.push('/');
}
return;
}
this.rss3 = await RSS3.get();
if (sessionStorage.getItem('profile')) {
Expand Down
9 changes: 7 additions & 2 deletions src/views/Setup/SetupFootprints.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,13 @@ export default class SetupFootprints extends Vue {

async mounted() {
if (!(await RSS3.reconnect())) {
sessionStorage.setItem('redirectFrom', this.$route.fullPath);
await this.$router.push('/');
if (config.subDomain.isSubDomainMode) {
// redirect back to root domain
window.location.host = config.subDomain.rootDomain;
} else {
sessionStorage.setItem('redirectFrom', this.$route.fullPath);
await this.$router.push('/');
}
return;
}
this.rss3 = await RSS3.get();
Expand Down
9 changes: 7 additions & 2 deletions src/views/Setup/SetupGitcoins.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,13 @@ export default class SetupGitcoins extends Vue {

async mounted() {
if (!(await RSS3.reconnect())) {
sessionStorage.setItem('redirectFrom', this.$route.fullPath);
await this.$router.push('/');
if (config.subDomain.isSubDomainMode) {
// redirect back to root domain
window.location.host = config.subDomain.rootDomain;
} else {
sessionStorage.setItem('redirectFrom', this.$route.fullPath);
await this.$router.push('/');
}
return;
}
this.rss3 = await RSS3.get();
Expand Down
9 changes: 7 additions & 2 deletions src/views/Setup/SetupNFTs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,13 @@ export default class SetupNFTs extends Vue {

async mounted() {
if (!(await RSS3.reconnect())) {
sessionStorage.setItem('redirectFrom', this.$route.fullPath);
await this.$router.push('/');
if (config.subDomain.isSubDomainMode) {
// redirect back to root domain
window.location.host = config.subDomain.rootDomain;
} else {
sessionStorage.setItem('redirectFrom', this.$route.fullPath);
await this.$router.push('/');
}
return;
}
this.rss3 = await RSS3.get();
Expand Down