Separate x / twitter redirects #822

This commit is contained in:
dangered wolf 2024-08-04 10:44:52 -07:00
parent 966ffd0ece
commit ac32c0a863
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
4 changed files with 9 additions and 3 deletions

View file

@ -17,6 +17,7 @@ export const Constants = {
GIF_TRANSCODE_DOMAIN: GIF_TRANSCODE_DOMAIN, GIF_TRANSCODE_DOMAIN: GIF_TRANSCODE_DOMAIN,
API_DOCS_URL: `https://github.com/FixTweet/FxTwitter/wiki/API-Home`, API_DOCS_URL: `https://github.com/FixTweet/FxTwitter/wiki/API-Home`,
TWITTER_ROOT: 'https://twitter.com', TWITTER_ROOT: 'https://twitter.com',
X_ROOT: 'https://x.com',
TWITTER_GLOBAL_NAME_ROOT: 'twitter.com', TWITTER_GLOBAL_NAME_ROOT: 'twitter.com',
TWITTER_API_ROOT: 'https://api.twitter.com', TWITTER_API_ROOT: 'https://api.twitter.com',
TWITTER_VIDEO_BASE: 'https://video.twimg.com', TWITTER_VIDEO_BASE: 'https://video.twimg.com',

View file

@ -24,7 +24,12 @@ export const getBaseRedirectUrl = (c: Context) => {
return baseRedirect.endsWith('/') ? baseRedirect.slice(0, -1) : baseRedirect; return baseRedirect.endsWith('/') ? baseRedirect.slice(0, -1) : baseRedirect;
} }
return Constants.TWITTER_ROOT; // Workaround to redirect to correct root depending on request URL
if (c.req.url.includes('fixup')) {
return Constants.X_ROOT
} else {
return Constants.TWITTER_ROOT;
}
}; };
/* Workaround for some dumb maybe-build time issue where statusRequest isn't ready or something because none of these trigger*/ /* Workaround for some dumb maybe-build time issue where statusRequest isn't ready or something because none of these trigger*/

View file

@ -14,7 +14,7 @@ export const genericTwitterRedirect = async (c: Context) => {
c.header('cache-control', cacheControl); c.header('cache-control', cacheControl);
} }
return c.redirect(`${baseUrl}${url.pathname}`, 302); return c.redirect(`${baseUrl}${url.pathname}?mx=1`, 302);
}; };
export const setRedirectRequest = async (c: Context) => { export const setRedirectRequest = async (c: Context) => {

View file

@ -119,7 +119,7 @@ export const statusRequest = async (c: Context) => {
if (!isBotUA && !flags.api && !flags.direct) { if (!isBotUA && !flags.api && !flags.direct) {
const baseUrl = getBaseRedirectUrl(c); const baseUrl = getBaseRedirectUrl(c);
return c.redirect(`${baseUrl}/${handle || 'i'}/status/${id}`, 302); return c.redirect(`${baseUrl}/${handle || 'i'}/status/${id}?mx=1`, 302);
} }
c.status(200); c.status(200);