better open.lbry.com redirect handling for lbry.tv
This commit is contained in:
parent
24edbc085c
commit
8839bb08db
5 changed files with 52 additions and 34 deletions
|
@ -1,7 +1,7 @@
|
||||||
const config = {
|
const config = {
|
||||||
WEBPACK_WEB_PORT: 9090,
|
WEBPACK_WEB_PORT: 9090,
|
||||||
WEBPACK_ELECTRON_PORT: 9091,
|
WEBPACK_ELECTRON_PORT: 9091,
|
||||||
WEB_SERVER_PORT: 1337,
|
WEB_SERVER_PORT: 80,
|
||||||
DOMAIN: 'lbry.tv',
|
DOMAIN: 'lbry.tv',
|
||||||
URL: 'https://lbry.tv',
|
URL: 'https://lbry.tv',
|
||||||
SITE_TITLE: 'lbry.tv',
|
SITE_TITLE: 'lbry.tv',
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const config = require('../../config');
|
const config = require('../../config');
|
||||||
const redirectHosts = ['open.lbry.com'];
|
const PAGES = require('../../ui/constants/pages');
|
||||||
|
|
||||||
async function redirectMiddleware(ctx, next) {
|
async function redirectMiddleware(ctx, next) {
|
||||||
const requestHost = ctx.host;
|
const requestHost = ctx.host;
|
||||||
|
@ -16,8 +16,24 @@ async function redirectMiddleware(ctx, next) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redirectHosts.includes(requestHost)) {
|
if (requestHost === 'open.lbry.com') {
|
||||||
const redirectUrl = config.URL + path;
|
let redirectUrl = config.URL;
|
||||||
|
const openQuery = '?src=open';
|
||||||
|
const matches = /(\/\?)([a-z]*)(.*)/.exec(url);
|
||||||
|
|
||||||
|
if (matches && matches.length) {
|
||||||
|
[, , page, queryString] = matches;
|
||||||
|
|
||||||
|
// This is a lbry app page. Make sure to add the leading `/$/`
|
||||||
|
if (page && Object.values(PAGES).includes(page)) {
|
||||||
|
redirectUrl += '/$/' + page;
|
||||||
|
}
|
||||||
|
|
||||||
|
redirectUrl += openQuery + queryString;
|
||||||
|
} else {
|
||||||
|
redirectUrl += path + openQuery;
|
||||||
|
}
|
||||||
|
|
||||||
ctx.redirect(redirectUrl);
|
ctx.redirect(redirectUrl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
export const AUTH = 'signin';
|
exports.AUTH = 'signin';
|
||||||
export const AUTH_VERIFY = 'verify';
|
exports.AUTH_VERIFY = 'verify';
|
||||||
export const BACKUP = 'backup';
|
exports.BACKUP = 'backup';
|
||||||
export const CHANNEL = 'channel';
|
exports.CHANNEL = 'channel';
|
||||||
export const DISCOVER = 'discover';
|
exports.DISCOVER = 'discover';
|
||||||
export const DOWNLOADED = 'downloaded';
|
exports.DOWNLOADED = 'downloaded';
|
||||||
export const HELP = 'help';
|
exports.HELP = 'help';
|
||||||
export const LIBRARY = 'library';
|
exports.LIBRARY = 'library';
|
||||||
export const INVITE = 'invite';
|
exports.INVITE = 'invite';
|
||||||
export const PUBLISH = 'publish';
|
exports.PUBLISH = 'publish';
|
||||||
export const PUBLISHED = 'published';
|
exports.PUBLISHED = 'published';
|
||||||
export const GET_CREDITS = 'getcredits';
|
exports.GET_CREDITS = 'getcredits';
|
||||||
export const REPORT = 'report';
|
exports.REPORT = 'report';
|
||||||
export const REWARDS = 'rewards';
|
exports.REWARDS = 'rewards';
|
||||||
export const SEND = 'send';
|
exports.SEND = 'send';
|
||||||
export const SETTINGS = 'settings';
|
exports.SETTINGS = 'settings';
|
||||||
export const SHOW = 'show';
|
exports.SHOW = 'show';
|
||||||
export const ACCOUNT = 'account';
|
exports.ACCOUNT = 'account';
|
||||||
export const FOLLOWING = 'following';
|
exports.FOLLOWING = 'following';
|
||||||
export const SEARCH = 'search';
|
exports.SEARCH = 'search';
|
||||||
export const TRANSACTIONS = 'transactions';
|
exports.TRANSACTIONS = 'transactions';
|
||||||
export const TAGS = 'tags';
|
exports.TAGS = 'tags';
|
||||||
export const WALLET = 'wallet';
|
exports.WALLET = 'wallet';
|
||||||
export const BLOCKED = 'blocked';
|
exports.BLOCKED = 'blocked';
|
||||||
export const CHANNELS = 'channels';
|
exports.CHANNELS = 'channels';
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'babel-polyfill';
|
||||||
|
|
||||||
import ErrorBoundary from 'component/errorBoundary';
|
import ErrorBoundary from 'component/errorBoundary';
|
||||||
import App from 'component/app';
|
import App from 'component/app';
|
||||||
import SnackBar from 'component/snackBar';
|
import SnackBar from 'component/snackBar';
|
||||||
|
|
10
yarn.lock
10
yarn.lock
|
@ -8118,10 +8118,10 @@ node-releases@^1.1.38:
|
||||||
dependencies:
|
dependencies:
|
||||||
semver "^6.3.0"
|
semver "^6.3.0"
|
||||||
|
|
||||||
node-sass@^4.11.0:
|
node-sass@^4.13.0:
|
||||||
version "4.12.0"
|
version "4.13.0"
|
||||||
resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.12.0.tgz#0914f531932380114a30cc5fa4fa63233a25f017"
|
resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.13.0.tgz#b647288babdd6a1cb726de4545516b31f90da066"
|
||||||
integrity sha512-A1Iv4oN+Iel6EPv77/HddXErL2a+gZ4uBeZUy+a8O35CFYTXhgA8MgLCWBtwpGZdCvTvQ9d+bQxX/QC36GDPpQ==
|
integrity sha512-W1XBrvoJ1dy7VsvTAS5q1V45lREbTlZQqFbiHb3R3OTTCma0XBtuG6xZ6Z4506nR4lmHPTqVRwxT6KgtWC97CA==
|
||||||
dependencies:
|
dependencies:
|
||||||
async-foreach "^0.1.3"
|
async-foreach "^0.1.3"
|
||||||
chalk "^1.1.1"
|
chalk "^1.1.1"
|
||||||
|
@ -8130,7 +8130,7 @@ node-sass@^4.11.0:
|
||||||
get-stdin "^4.0.1"
|
get-stdin "^4.0.1"
|
||||||
glob "^7.0.3"
|
glob "^7.0.3"
|
||||||
in-publish "^2.0.0"
|
in-publish "^2.0.0"
|
||||||
lodash "^4.17.11"
|
lodash "^4.17.15"
|
||||||
meow "^3.7.0"
|
meow "^3.7.0"
|
||||||
mkdirp "^0.5.1"
|
mkdirp "^0.5.1"
|
||||||
nan "^2.13.2"
|
nan "^2.13.2"
|
||||||
|
|
Loading…
Add table
Reference in a new issue