diff options
| author | Freya Murphy <freya@freyacat.org> | 2026-03-02 16:05:12 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2026-03-05 12:55:43 -0500 |
| commit | 587ab8500abb2d8b0a494dc05952c9919cc7f66f (patch) | |
| tree | 07f50e1153a029158baed106aa8367c9fa32cd7a /packages/backend/src/config.ts | |
| parent | Merge pull request #17217 from misskey-dev/develop (diff) | |
| download | misskey-587ab8500abb2d8b0a494dc05952c9919cc7f66f.tar.gz misskey-587ab8500abb2d8b0a494dc05952c9919cc7f66f.tar.bz2 misskey-587ab8500abb2d8b0a494dc05952c9919cc7f66f.zip | |
split url into webUrl and localUrl (like mastodon)
Diffstat (limited to 'packages/backend/src/config.ts')
| -rw-r--r-- | packages/backend/src/config.ts | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index 4cd82bed87..8dafe91d26 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -26,6 +26,8 @@ type RedisOptionsSource = Partial<RedisOptions> & { */ type Source = { url?: string; + localUrl?: string; + webUrl?: string; port?: number; socket?: string; trustProxy?: FastifyServerOptions['trustProxy']; @@ -118,7 +120,8 @@ type Source = { }; export type Config = { - url: string; + localUrl: string; + webUrl: string; port: number; socket: string | undefined; trustProxy: NonNullable<FastifyServerOptions['trustProxy']>; @@ -180,8 +183,10 @@ export type Config = { version: string; publishTarballInsteadOfProvideRepositoryUrl: boolean; setupPassword: string | undefined; - host: string; - hostname: string; + localHost: string; + localHostname: string; + webHost: string; + webHostname: string; scheme: string; wsScheme: string; apiUrl: string; @@ -259,11 +264,14 @@ export function loadConfig(): Config { const config = JSON.parse(fs.readFileSync(compiledConfigFilePath, 'utf-8')) as Source; - const url = tryCreateUrl(config.url ?? process.env.MISSKEY_URL ?? ''); + const localUrl = tryCreateUrl(config.url ?? config.localUrl ?? process.env.MISSKEY_URL ?? ''); + const webUrl = tryCreateUrl(config.webUrl ?? process.env.MISSKEY_WEB_URL ?? localUrl ?? ''); const version = meta.version; - const host = url.host; - const hostname = url.hostname; - const scheme = url.protocol.replace(/:$/, ''); + const localHost = localUrl.host; + const localHostname = localUrl.hostname; + const webHost = webUrl.host; + const webHostname = webUrl.hostname; + const scheme = webUrl.protocol.replace(/:$/, ''); const wsScheme = scheme.replace('http', 'ws'); const dbDb = config.db.db ?? process.env.DATABASE_DB ?? ''; @@ -273,14 +281,15 @@ export function loadConfig(): Config { const externalMediaProxy = config.mediaProxy ? config.mediaProxy.endsWith('/') ? config.mediaProxy.substring(0, config.mediaProxy.length - 1) : config.mediaProxy : null; - const internalMediaProxy = `${scheme}://${host}/proxy`; - const redis = convertRedisOptions(config.redis, host); + const internalMediaProxy = `${scheme}://${webHost}/proxy`; + const redis = convertRedisOptions(config.redis, localHost); return { version, publishTarballInsteadOfProvideRepositoryUrl: !!config.publishTarballInsteadOfProvideRepositoryUrl, setupPassword: config.setupPassword, - url: url.origin, + localUrl: localUrl.origin, + webUrl: webUrl.origin, port: config.port ?? parseInt(process.env.PORT ?? '', 10), socket: config.socket, trustProxy: config.trustProxy ?? [ @@ -294,24 +303,26 @@ export function loadConfig(): Config { chmodSocket: config.chmodSocket, disableHsts: config.disableHsts, enableIpRateLimit: config.enableIpRateLimit ?? true, - host, - hostname, + localHost, + localHostname, + webHost, + webHostname, scheme, wsScheme, - wsUrl: `${wsScheme}://${host}`, - apiUrl: `${scheme}://${host}/api`, - authUrl: `${scheme}://${host}/auth`, - driveUrl: `${scheme}://${host}/files`, + wsUrl: `${wsScheme}://${webHost}`, + apiUrl: `${scheme}://${webHost}/api`, + authUrl: `${scheme}://${webHost}/auth`, + driveUrl: `${scheme}://${webHost}/files`, db: { ...config.db, db: dbDb, user: dbUser, pass: dbPass }, dbReplications: config.dbReplications, dbSlaves: config.dbSlaves, fulltextSearch: config.fulltextSearch, meilisearch: config.meilisearch, redis, - redisForPubsub: config.redisForPubsub ? convertRedisOptions(config.redisForPubsub, host) : redis, - redisForJobQueue: config.redisForJobQueue ? convertRedisOptions(config.redisForJobQueue, host) : redis, - redisForTimelines: config.redisForTimelines ? convertRedisOptions(config.redisForTimelines, host) : redis, - redisForReactions: config.redisForReactions ? convertRedisOptions(config.redisForReactions, host) : redis, + redisForPubsub: config.redisForPubsub ? convertRedisOptions(config.redisForPubsub, webHost) : redis, + redisForJobQueue: config.redisForJobQueue ? convertRedisOptions(config.redisForJobQueue, webHost) : redis, + redisForTimelines: config.redisForTimelines ? convertRedisOptions(config.redisForTimelines, webHost) : redis, + redisForReactions: config.redisForReactions ? convertRedisOptions(config.redisForReactions, webHost) : redis, sentryForBackend: config.sentryForBackend, sentryForFrontend: config.sentryForFrontend, id: config.id, @@ -336,7 +347,7 @@ export function loadConfig(): Config { videoThumbnailGenerator: config.videoThumbnailGenerator ? config.videoThumbnailGenerator.endsWith('/') ? config.videoThumbnailGenerator.substring(0, config.videoThumbnailGenerator.length - 1) : config.videoThumbnailGenerator : null, - userAgent: `Misskey/${version} (${config.url})`, + userAgent: `Misskey/${version} (${config.localUrl})`, frontendEntry: frontendManifest['src/_boot_.ts'], frontendManifestExists: frontendManifestExists, frontendEmbedEntry: frontendEmbedManifest['src/boot.ts'], |