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 | |
| 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')
59 files changed, 166 insertions, 148 deletions
diff --git a/packages/backend/src/GlobalModule.ts b/packages/backend/src/GlobalModule.ts index 435bd8dd45..eaaaf1e284 100644 --- a/packages/backend/src/GlobalModule.ts +++ b/packages/backend/src/GlobalModule.ts @@ -75,7 +75,7 @@ const $redisForSub: Provider = { provide: DI.redisForSub, useFactory: (config: Config) => { const redis = new Redis.Redis(config.redisForPubsub); - redis.subscribe(config.host); + redis.subscribe(config.webHost); return redis; }, inject: [DI.config], diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts index 041f58e509..94a3fe2aff 100644 --- a/packages/backend/src/boot/master.ts +++ b/packages/backend/src/boot/master.ts @@ -120,7 +120,7 @@ export async function masterMain() { if (envOption.onlyQueue) { bootLogger.succ('Queue started', null, true); } else { - bootLogger.succ(config.socket ? `Now listening on socket ${config.socket} on ${config.url}` : `Now listening on port ${config.port} on ${config.url}`, null, true); + bootLogger.succ(config.socket ? `Now listening on socket ${config.socket} on ${config.webUrl}` : `Now listening on port ${config.port} on ${config.webUrl}`, null, true); } } 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'], diff --git a/packages/backend/src/core/ChatService.ts b/packages/backend/src/core/ChatService.ts index 5cd336a097..b1a79090aa 100644 --- a/packages/backend/src/core/ChatService.ts +++ b/packages/backend/src/core/ChatService.ts @@ -379,7 +379,7 @@ export class ChatService { if (this.userEntityService.isLocalUser(toUser)) this.globalEventService.publishChatUserStream(message.toUserId, message.fromUserId, 'deleted', message.id); if (this.userEntityService.isLocalUser(fromUser) && this.userEntityService.isRemoteUser(toUser)) { - //const activity = this.apRendererService.addContext(this.apRendererService.renderDelete(this.apRendererService.renderTombstone(`${this.config.url}/notes/${message.id}`), fromUser)); + //const activity = this.apRendererService.addContext(this.apRendererService.renderDelete(this.apRendererService.renderTombstone(`${this.config.webUrl}/notes/${message.id}`), fromUser)); //this.queueService.deliver(fromUser, activity, toUser.inbox); } } else if (message.toRoomId) { diff --git a/packages/backend/src/core/EmailService.ts b/packages/backend/src/core/EmailService.ts index 384704b252..eb5490101b 100644 --- a/packages/backend/src/core/EmailService.ts +++ b/packages/backend/src/core/EmailService.ts @@ -42,8 +42,8 @@ export class EmailService { public async sendEmail(to: string, subject: string, html: string, text: string) { if (!this.meta.enableEmail) return; - const iconUrl = `${this.config.url}/static-assets/mi-white.png`; - const emailSettingUrl = `${this.config.url}/settings/email`; + const iconUrl = `${this.config.webUrl}/static-assets/mi-white.png`; + const emailSettingUrl = `${this.config.webUrl}/settings/email`; const enableAuth = this.meta.smtpUser != null && this.meta.smtpUser !== ''; @@ -135,7 +135,7 @@ export class EmailService { </footer> </main> <nav> - <a href="${ this.config.url }">${ this.config.host }</a> + <a href="${ this.config.webUrl }">${ this.config.webHost }</a> </nav> </body> </html>`; diff --git a/packages/backend/src/core/GlobalEventService.ts b/packages/backend/src/core/GlobalEventService.ts index da5982abf6..a6d6baf2cb 100644 --- a/packages/backend/src/core/GlobalEventService.ts +++ b/packages/backend/src/core/GlobalEventService.ts @@ -351,7 +351,7 @@ export class GlobalEventService { { type: type, body: null } : { type: type, body: value }; - this.redisForPub.publish(this.config.host, JSON.stringify({ + this.redisForPub.publish(this.config.webHost, JSON.stringify({ channel: channel, message: message, })); diff --git a/packages/backend/src/core/InternalStorageService.ts b/packages/backend/src/core/InternalStorageService.ts index 4fb8a93e49..f189d55d11 100644 --- a/packages/backend/src/core/InternalStorageService.ts +++ b/packages/backend/src/core/InternalStorageService.ts @@ -39,14 +39,14 @@ export class InternalStorageService { public saveFromPath(key: string, srcPath: string) { fs.mkdirSync(path, { recursive: true }); fs.copyFileSync(srcPath, this.resolvePath(key)); - return `${this.config.url}/files/${key}`; + return `${this.config.webUrl}/files/${key}`; } @bindThis public saveFromBuffer(key: string, data: Buffer) { fs.mkdirSync(path, { recursive: true }); fs.writeFileSync(this.resolvePath(key), data); - return `${this.config.url}/files/${key}`; + return `${this.config.webUrl}/files/${key}`; } @bindThis diff --git a/packages/backend/src/core/MfmService.ts b/packages/backend/src/core/MfmService.ts index 274966d921..b633839de8 100644 --- a/packages/backend/src/core/MfmService.ts +++ b/packages/backend/src/core/MfmService.ts @@ -357,7 +357,7 @@ export class MfmService { }, hashtag: (node) => { - return `<a href="${escapeHtml(`${this.config.url}/tags/${encodeURIComponent(node.props.hashtag)}`)}" rel="tag">#${escapeHtml(node.props.hashtag)}</a>`; + return `<a href="${escapeHtml(`${this.config.webUrl}/tags/${encodeURIComponent(node.props.hashtag)}`)}" rel="tag">#${escapeHtml(node.props.hashtag)}</a>`; }, inlineCode: (node) => { @@ -386,7 +386,7 @@ export class MfmService { const remoteUserInfo = mentionedRemoteUsers.find(remoteUser => remoteUser.username.toLowerCase() === username.toLowerCase() && remoteUser.host?.toLowerCase() === host?.toLowerCase()); const href = remoteUserInfo ? (remoteUserInfo.url ? remoteUserInfo.url : remoteUserInfo.uri) - : `${this.config.url}/${acct.endsWith(`@${this.config.url}`) ? acct.substring(0, acct.length - this.config.url.length - 1) : acct}`; + : `${this.config.webUrl}/${acct.endsWith(`@${this.config.localUrl}`) ? acct.substring(0, acct.length - this.config.localUrl.length - 1) : acct}`; try { const url = new URL(href); return `<a href="${escapeHtml(url.href)}" class="u-url mention">${escapeHtml(acct)}</a>`; diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 748f2cbad9..7fb5515959 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -950,7 +950,7 @@ export class NoteCreateService implements OnApplicationShutdown { if (data.localOnly) return null; const content = this.isRenote(data) && !this.isQuote(data) - ? this.apRendererService.renderAnnounce(data.renote.uri ? data.renote.uri : `${this.config.url}/notes/${data.renote.id}`, note) + ? this.apRendererService.renderAnnounce(data.renote.uri ? data.renote.uri : `${this.config.webUrl}/notes/${data.renote.id}`, note) : this.apRendererService.renderCreate(await this.apRendererService.renderNote(note, false), note); return this.apRendererService.addContext(content); diff --git a/packages/backend/src/core/NoteDeleteService.ts b/packages/backend/src/core/NoteDeleteService.ts index af1f0eda9a..dee115b548 100644 --- a/packages/backend/src/core/NoteDeleteService.ts +++ b/packages/backend/src/core/NoteDeleteService.ts @@ -84,8 +84,8 @@ export class NoteDeleteService { } const content = this.apRendererService.addContext(renote - ? this.apRendererService.renderUndo(this.apRendererService.renderAnnounce(renote.uri ?? `${this.config.url}/notes/${renote.id}`, note), user) - : this.apRendererService.renderDelete(this.apRendererService.renderTombstone(`${this.config.url}/notes/${note.id}`), user)); + ? this.apRendererService.renderUndo(this.apRendererService.renderAnnounce(renote.uri ?? `${this.config.webUrl}/notes/${renote.id}`, note), user) + : this.apRendererService.renderDelete(this.apRendererService.renderTombstone(`${this.config.webUrl}/notes/${note.id}`), user)); this.deliverToConcerned(user, note, content); } diff --git a/packages/backend/src/core/NotePiningService.ts b/packages/backend/src/core/NotePiningService.ts index d38b48b65d..3665dd5f03 100644 --- a/packages/backend/src/core/NotePiningService.ts +++ b/packages/backend/src/core/NotePiningService.ts @@ -117,8 +117,8 @@ export class NotePiningService { if (!this.userEntityService.isLocalUser(user)) return; - const target = `${this.config.url}/users/${user.id}/collections/featured`; - const item = `${this.config.url}/notes/${noteId}`; + const target = `${this.config.webUrl}/users/${user.id}/collections/featured`; + const item = `${this.config.webUrl}/notes/${noteId}`; const content = this.apRendererService.addContext(isAddition ? this.apRendererService.renderAdd(user, target, item) : this.apRendererService.renderRemove(user, target, item)); this.apDeliverManagerService.deliverToFollowers(user, content); diff --git a/packages/backend/src/core/PushNotificationService.ts b/packages/backend/src/core/PushNotificationService.ts index 9333c1ebc5..e9ded5f282 100644 --- a/packages/backend/src/core/PushNotificationService.ts +++ b/packages/backend/src/core/PushNotificationService.ts @@ -77,7 +77,7 @@ export class PushNotificationService implements OnApplicationShutdown { if (!this.meta.enableServiceWorker || this.meta.swPublicKey == null || this.meta.swPrivateKey == null) return; // アプリケーションの連絡先と、サーバーサイドの鍵ペアの情報を登録 - push.setVapidDetails(this.config.url, + push.setVapidDetails(this.config.webUrl, this.meta.swPublicKey, this.meta.swPrivateKey); diff --git a/packages/backend/src/core/RemoteUserResolveService.ts b/packages/backend/src/core/RemoteUserResolveService.ts index a2f1b73cdb..55c03e9777 100644 --- a/packages/backend/src/core/RemoteUserResolveService.ts +++ b/packages/backend/src/core/RemoteUserResolveService.ts @@ -56,7 +56,7 @@ export class RemoteUserResolveService { host = this.utilityService.toPuny(host); - if (host === this.utilityService.toPuny(this.config.host)) { + if (host === this.utilityService.toPuny(this.config.localHost)) { this.logger.info(`return local user: ${usernameLower}`); return await this.usersRepository.findOneBy({ usernameLower, host: IsNull() }).then(u => { if (u == null) { diff --git a/packages/backend/src/core/UserFollowingService.ts b/packages/backend/src/core/UserFollowingService.ts index e7a6be99fb..9d2ab73fe8 100644 --- a/packages/backend/src/core/UserFollowingService.ts +++ b/packages/backend/src/core/UserFollowingService.ts @@ -536,7 +536,7 @@ export class UserFollowingService implements OnModuleInit { } if (this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee)) { - const content = this.apRendererService.addContext(this.apRendererService.renderFollow(follower as MiPartialLocalUser, followee as MiPartialRemoteUser, requestId ?? `${this.config.url}/follows/${followRequest.id}`)); + const content = this.apRendererService.addContext(this.apRendererService.renderFollow(follower as MiPartialLocalUser, followee as MiPartialRemoteUser, requestId ?? `${this.config.webUrl}/follows/${followRequest.id}`)); this.queueService.deliver(follower, content, followee.inbox, false); } } diff --git a/packages/backend/src/core/UserSearchService.ts b/packages/backend/src/core/UserSearchService.ts index 4be7bd9bdb..15245c39b7 100644 --- a/packages/backend/src/core/UserSearchService.ts +++ b/packages/backend/src/core/UserSearchService.ts @@ -198,7 +198,7 @@ export class UserSearchService { } if (params.host) { - if (params.host === this.config.hostname || params.host === '.') { + if (params.host === this.config.localHostname || params.host === '.') { userQuery.andWhere('user.host IS NULL'); } else { userQuery.andWhere('user.host LIKE :host', { diff --git a/packages/backend/src/core/UtilityService.ts b/packages/backend/src/core/UtilityService.ts index e3ceebccae..38390d0a2c 100644 --- a/packages/backend/src/core/UtilityService.ts +++ b/packages/backend/src/core/UtilityService.ts @@ -26,18 +26,20 @@ export class UtilityService { @bindThis public getFullApAccount(username: string, host: string | null): string { - return host ? `${username}@${this.toPuny(host)}` : `${username}@${this.toPuny(this.config.host)}`; + return host ? `${username}@${this.toPuny(host)}` : `${username}@${this.toPuny(this.config.localHost)}`; } @bindThis public isSelfHost(host: string | null): boolean { if (host == null) return true; - return this.toPuny(this.config.host) === this.toPuny(host); + return (this.toPuny(this.config.localHost) === this.toPuny(host)) || + (this.toPuny(this.config.webHost) === this.toPuny(host)) } @bindThis public isUriLocal(uri: string): boolean { - return this.punyHost(uri) === this.toPuny(this.config.host); + return (this.punyHost(uri) === this.toPuny(this.config.localHost)) || + (this.punyHost(uri) === this.toPuny(this.config.webHost)) } // メールアドレスのバリデーションを行う diff --git a/packages/backend/src/core/WebAuthnService.ts b/packages/backend/src/core/WebAuthnService.ts index 31c8d67c60..f0dc9dc104 100644 --- a/packages/backend/src/core/WebAuthnService.ts +++ b/packages/backend/src/core/WebAuthnService.ts @@ -46,9 +46,9 @@ export class WebAuthnService { @bindThis public getRelyingParty(): { origin: string; rpId: string; rpName: string; rpIcon?: string; } { return { - origin: this.config.url, - rpId: this.config.hostname, - rpName: this.meta.name ?? this.config.host, + origin: this.config.webUrl, + rpId: this.config.webHostname, + rpName: this.meta.name ?? this.config.webHost, rpIcon: this.meta.iconUrl ?? undefined, }; } diff --git a/packages/backend/src/core/activitypub/ApDbResolverService.ts b/packages/backend/src/core/activitypub/ApDbResolverService.ts index 5c16744a77..69933aaef6 100644 --- a/packages/backend/src/core/activitypub/ApDbResolverService.ts +++ b/packages/backend/src/core/activitypub/ApDbResolverService.ts @@ -65,9 +65,9 @@ export class ApDbResolverService implements OnApplicationShutdown { const separator = '/'; const uri = new URL(getApId(value)); - if (this.utilityService.toPuny(uri.host) !== this.utilityService.toPuny(this.config.host)) { + if ((this.utilityService.toPuny(uri.host) !== this.utilityService.toPuny(this.config.localHost)) && + (this.utilityService.toPuny(uri.host) !== this.utilityService.toPuny(this.config.webHost))) return { local: false, uri: uri.href }; - } const [, type, id, ...rest] = uri.pathname.split(separator); return { diff --git a/packages/backend/src/core/activitypub/ApInboxService.ts b/packages/backend/src/core/activitypub/ApInboxService.ts index ff47ca930d..1173c4bcce 100644 --- a/packages/backend/src/core/activitypub/ApInboxService.ts +++ b/packages/backend/src/core/activitypub/ApInboxService.ts @@ -549,7 +549,7 @@ export class ApInboxService { const uris = getApIds(activity.object); const userIds = uris - .filter(uri => uri.startsWith(this.config.url + '/users/')) + .filter(uri => uri.startsWith(this.config.webUrl + '/users/')) .map(uri => uri.split('/').at(-1)) .filter(x => x != null); const users = await this.usersRepository.findBy({ diff --git a/packages/backend/src/core/activitypub/ApRendererService.ts b/packages/backend/src/core/activitypub/ApRendererService.ts index 8c461b6031..d50d72d188 100644 --- a/packages/backend/src/core/activitypub/ApRendererService.ts +++ b/packages/backend/src/core/activitypub/ApRendererService.ts @@ -110,7 +110,7 @@ export class ApRendererService { } return { - id: `${this.config.url}/notes/${note.id}/activity`, + id: `${this.config.webUrl}/notes/${note.id}/activity`, actor: this.userEntityService.genLocalUserUri(note.userId), type: 'Announce', published: this.idService.parse(note.id).date.toISOString(), @@ -133,7 +133,7 @@ export class ApRendererService { return { type: 'Block', - id: `${this.config.url}/blocks/${block.id}`, + id: `${this.config.webUrl}/blocks/${block.id}`, actor: this.userEntityService.genLocalUserUri(block.blockerId), object: block.blockee.uri, }; @@ -142,7 +142,7 @@ export class ApRendererService { @bindThis public renderCreate(object: IObject, note: MiNote): ICreate { const activity: ICreate = { - id: `${this.config.url}/notes/${note.id}/activity`, + id: `${this.config.webUrl}/notes/${note.id}/activity`, actor: this.userEntityService.genLocalUserUri(note.userId), type: 'Create', published: this.idService.parse(note.id).date.toISOString(), @@ -179,7 +179,7 @@ export class ApRendererService { @bindThis public renderEmoji(emoji: MiEmoji): IApEmoji { return { - id: `${this.config.url}/emojis/${emoji.name}`, + id: `${this.config.webUrl}/emojis/${emoji.name}`, type: 'Emoji', name: `:${emoji.name}:`, updated: emoji.updatedAt != null ? emoji.updatedAt.toISOString() : new Date().toISOString(), @@ -209,7 +209,7 @@ export class ApRendererService { @bindThis public renderFollowRelay(relay: MiRelay, relayActor: MiLocalUser): IFollow { return { - id: `${this.config.url}/activities/follow-relay/${relay.id}`, + id: `${this.config.webUrl}/activities/follow-relay/${relay.id}`, type: 'Follow', actor: this.userEntityService.genLocalUserUri(relayActor.id), object: 'https://www.w3.org/ns/activitystreams#Public', @@ -233,7 +233,7 @@ export class ApRendererService { requestId?: string, ): IFollow { return { - id: requestId ?? `${this.config.url}/follows/${follower.id}/${followee.id}`, + id: requestId ?? `${this.config.webUrl}/follows/${follower.id}/${followee.id}`, type: 'Follow', actor: this.userEntityService.getUserUri(follower), object: this.userEntityService.getUserUri(followee), @@ -244,7 +244,7 @@ export class ApRendererService { public renderHashtag(tag: string): IApHashtag { return { type: 'Hashtag', - href: `${this.config.url}/tags/${encodeURIComponent(tag)}`, + href: `${this.config.webUrl}/tags/${encodeURIComponent(tag)}`, name: `#${tag}`, }; } @@ -294,7 +294,7 @@ export class ApRendererService { @bindThis public renderKey(user: MiLocalUser, key: MiUserKeypair, postfix?: string): IKey { return { - id: `${this.config.url}/users/${user.id}${postfix ?? '/publickey'}`, + id: `${this.config.webUrl}/users/${user.id}${postfix ?? '/publickey'}`, type: 'Key', owner: this.userEntityService.genLocalUserUri(user.id), publicKeyPem: createPublicKey(key.publicKey).export({ @@ -310,9 +310,9 @@ export class ApRendererService { const object: ILike = { type: 'Like', - id: `${this.config.url}/likes/${noteReaction.id}`, - actor: `${this.config.url}/users/${noteReaction.userId}`, - object: note.uri ? note.uri : `${this.config.url}/notes/${noteReaction.noteId}`, + id: `${this.config.webUrl}/likes/${noteReaction.id}`, + actor: `${this.config.webUrl}/users/${noteReaction.userId}`, + object: note.uri ? note.uri : `${this.config.webUrl}/notes/${noteReaction.noteId}`, content: reaction, _misskey_reaction: reaction, }; @@ -344,7 +344,7 @@ export class ApRendererService { const actor = this.userEntityService.getUserUri(src); const target = this.userEntityService.getUserUri(dst); return { - id: `${this.config.url}/moves/${src.id}/${dst.id}`, + id: `${this.config.webUrl}/moves/${src.id}/${dst.id}`, actor, type: 'Move', object: actor, @@ -376,7 +376,7 @@ export class ApRendererService { if (dive) { inReplyTo = await this.renderNote(inReplyToNote, false); } else { - inReplyTo = `${this.config.url}/notes/${inReplyToNote.id}`; + inReplyTo = `${this.config.webUrl}/notes/${inReplyToNote.id}`; } } } @@ -391,7 +391,7 @@ export class ApRendererService { const renote = await this.notesRepository.findOneBy({ id: note.renoteId }); if (renote) { - quote = renote.uri ? renote.uri : `${this.config.url}/notes/${renote.id}`; + quote = renote.uri ? renote.uri : `${this.config.webUrl}/notes/${renote.id}`; } } @@ -467,7 +467,7 @@ export class ApRendererService { } as const : {}; return { - id: `${this.config.url}/notes/${note.id}`, + id: `${this.config.webUrl}/notes/${note.id}`, type: 'Note', attributedTo, summary: summary ?? undefined, @@ -548,9 +548,9 @@ export class ApRendererService { followers: `${id}/followers`, following: `${id}/following`, featured: `${id}/collections/featured`, - sharedInbox: `${this.config.url}/inbox`, - endpoints: { sharedInbox: `${this.config.url}/inbox` }, - url: `${this.config.url}/@${user.username}`, + sharedInbox: `${this.config.webUrl}/inbox`, + endpoints: { sharedInbox: `${this.config.webUrl}/inbox` }, + url: `${this.config.webUrl}/@${user.username}`, preferredUsername: user.username, name: user.name, summary: profile.description ? this.mfmService.toHtml(mfm.parse(profile.description)) : null, @@ -592,7 +592,7 @@ export class ApRendererService { public renderQuestion(user: { id: MiUser['id'] }, note: MiNote, poll: MiPoll): IQuestion { return { type: 'Question', - id: `${this.config.url}/questions/${note.id}`, + id: `${this.config.webUrl}/questions/${note.id}`, actor: this.userEntityService.genLocalUserUri(user.id), content: note.text ?? '', [poll.multiple ? 'anyOf' : 'oneOf']: poll.choices.map((text, i) => ({ @@ -649,7 +649,7 @@ export class ApRendererService { @bindThis public renderUpdate(object: string | IObject, user: { id: MiUser['id'] }): IUpdate { return { - id: `${this.config.url}/users/${user.id}#updates/${new Date().getTime()}`, + id: `${this.config.webUrl}/users/${user.id}#updates/${new Date().getTime()}`, actor: this.userEntityService.genLocalUserUri(user.id), type: 'Update', to: ['https://www.w3.org/ns/activitystreams#Public'], @@ -661,13 +661,13 @@ export class ApRendererService { @bindThis public renderVote(user: { id: MiUser['id'] }, vote: MiPollVote, note: MiNote, poll: MiPoll, pollOwner: MiRemoteUser): ICreate { return { - id: `${this.config.url}/users/${user.id}#votes/${vote.id}/activity`, + id: `${this.config.webUrl}/users/${user.id}#votes/${vote.id}/activity`, actor: this.userEntityService.genLocalUserUri(user.id), type: 'Create', to: [pollOwner.uri], published: new Date().toISOString(), object: { - id: `${this.config.url}/users/${user.id}#votes/${vote.id}`, + id: `${this.config.webUrl}/users/${user.id}#votes/${vote.id}`, type: 'Note', attributedTo: this.userEntityService.genLocalUserUri(user.id), to: [pollOwner.uri], @@ -680,7 +680,7 @@ export class ApRendererService { @bindThis public addContext<T extends IObject>(x: T): T & { '@context': any; id: string; } { if (typeof x === 'object' && x.id == null) { - x.id = `${this.config.url}/${randomUUID()}`; + x.id = `${this.config.webUrl}/${randomUUID()}`; } return Object.assign({ '@context': CONTEXT }, x as T & { id: string }); @@ -692,7 +692,7 @@ export class ApRendererService { const jsonLd = this.jsonLdService.use(); jsonLd.debug = false; - activity = await jsonLd.signRsaSignature2017(activity, keypair.privateKey, `${this.config.url}/users/${user.id}#main-key`); + activity = await jsonLd.signRsaSignature2017(activity, keypair.privateKey, `${this.config.webUrl}/users/${user.id}#main-key`); return activity; } diff --git a/packages/backend/src/core/activitypub/ApRequestService.ts b/packages/backend/src/core/activitypub/ApRequestService.ts index d14b82dc92..df10d076cd 100644 --- a/packages/backend/src/core/activitypub/ApRequestService.ts +++ b/packages/backend/src/core/activitypub/ApRequestService.ts @@ -163,7 +163,7 @@ export class ApRequestService { const req = ApRequestCreator.createSignedPost({ key: { privateKeyPem: keypair.privateKey, - keyId: `${this.config.url}/users/${user.id}#main-key`, + keyId: `${this.config.webUrl}/users/${user.id}#main-key`, }, url, body, @@ -192,7 +192,7 @@ export class ApRequestService { const req = ApRequestCreator.createSignedGet({ key: { privateKeyPem: keypair.privateKey, - keyId: `${this.config.url}/users/${user.id}#main-key`, + keyId: `${this.config.webUrl}/users/${user.id}#main-key`, }, url, additionalHeaders: { diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts index ebe8e9c964..5336177965 100644 --- a/packages/backend/src/core/activitypub/models/ApPersonService.ts +++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts @@ -233,7 +233,7 @@ export class ApPersonService implements OnModuleInit { if (cached) return cached; // URIがこのサーバーを指しているならデータベースからフェッチ - if (uri.startsWith(`${this.config.url}/`)) { + if (uri.startsWith(`${this.config.webUrl}/`) || uri.startsWith(`${this.config.localUrl}/`)) { const id = uri.split('/').pop(); const u = await this.usersRepository.findOneBy({ id }) as MiLocalUser | null; if (u) this.cacheService.uriPersonCache.set(uri, u); @@ -305,7 +305,8 @@ export class ApPersonService implements OnModuleInit { if (typeof uri !== 'string') throw new Error('uri is not string'); const host = this.utilityService.punyHost(uri); - if (host === this.utilityService.toPuny(this.config.host)) { + if ((host === this.utilityService.toPuny(this.config.localHost)) || + (host === this.utilityService.toPuny(this.config.webHost))) { throw new StatusError('cannot resolve local user', 400, 'cannot resolve local user'); } diff --git a/packages/backend/src/core/entities/DriveFileEntityService.ts b/packages/backend/src/core/entities/DriveFileEntityService.ts index 1865d494c4..10e333c04b 100644 --- a/packages/backend/src/core/entities/DriveFileEntityService.ts +++ b/packages/backend/src/core/entities/DriveFileEntityService.ts @@ -123,7 +123,7 @@ export class DriveFileEntityService { const key = file.webpublicAccessKey; if (key && !key.match('/')) { // 古いものはここにオブジェクトストレージキーが入ってるので除外 - const url = `${this.config.url}/files/${key}`; + const url = `${this.config.webUrl}/files/${key}`; if (mode === 'avatar') return this.getProxiedUrl(file.uri, 'avatar'); return url; } diff --git a/packages/backend/src/core/entities/MetaEntityService.ts b/packages/backend/src/core/entities/MetaEntityService.ts index 8e56ddbc02..29790c79a0 100644 --- a/packages/backend/src/core/entities/MetaEntityService.ts +++ b/packages/backend/src/core/entities/MetaEntityService.ts @@ -74,7 +74,7 @@ export class MetaEntityService { name: instance.name, shortName: instance.shortName, - uri: this.config.url, + uri: this.config.webUrl, description: instance.description, langs: instance.langs, tosUrl: instance.termsOfServiceUrl, diff --git a/packages/backend/src/core/entities/UserEntityService.ts b/packages/backend/src/core/entities/UserEntityService.ts index 0f4051e7b8..eae9ade0d2 100644 --- a/packages/backend/src/core/entities/UserEntityService.ts +++ b/packages/backend/src/core/entities/UserEntityService.ts @@ -383,10 +383,10 @@ export class UserEntityService implements OnModuleInit { @bindThis public getIdenticonUrl(user: MiUser): string { - if ((user.host == null || user.host === this.config.host) && user.username.includes('.') && this.meta.iconUrl) { // ローカルのシステムアカウントの場合 + if ((user.host == null || user.host === this.config.localHost) && user.username.includes('.') && this.meta.iconUrl) { // ローカルのシステムアカウントの場合 return this.meta.iconUrl; } else { - return `${this.config.url}/identicon/${user.username.toLowerCase()}@${user.host ?? this.config.host}`; + return `${this.config.webUrl}/identicon/${user.username.toLowerCase()}@${user.host ?? this.config.localHost}`; } } @@ -398,7 +398,7 @@ export class UserEntityService implements OnModuleInit { @bindThis public genLocalUserUri(userId: string): string { - return `${this.config.url}/users/${userId}`; + return `${this.config.webUrl}/users/${userId}`; } public async pack<S extends 'MeDetailed' | 'UserDetailedNotMe' | 'UserDetailed' | 'UserLite' = 'UserLite'>( diff --git a/packages/backend/src/queue/processors/ExportCustomEmojisProcessorService.ts b/packages/backend/src/queue/processors/ExportCustomEmojisProcessorService.ts index 53ecd2d180..5a7bef824f 100644 --- a/packages/backend/src/queue/processors/ExportCustomEmojisProcessorService.ts +++ b/packages/backend/src/queue/processors/ExportCustomEmojisProcessorService.ts @@ -75,7 +75,7 @@ export class ExportCustomEmojisProcessorService { }); }; - await writeMeta(`{"metaVersion":2,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","emojis":[`); + await writeMeta(`{"metaVersion":2,"host":"${this.config.webHost}","exportedAt":"${new Date().toString()}","emojis":[`); const customEmojis = await this.emojisRepository.find({ where: { diff --git a/packages/backend/src/queue/processors/SystemWebhookDeliverProcessorService.ts b/packages/backend/src/queue/processors/SystemWebhookDeliverProcessorService.ts index f6bef52684..0d85812587 100644 --- a/packages/backend/src/queue/processors/SystemWebhookDeliverProcessorService.ts +++ b/packages/backend/src/queue/processors/SystemWebhookDeliverProcessorService.ts @@ -41,13 +41,13 @@ export class SystemWebhookDeliverProcessorService { method: 'POST', headers: { 'User-Agent': 'Misskey-Hooks', - 'X-Misskey-Host': this.config.host, + 'X-Misskey-Host': this.config.webHost, 'X-Misskey-Hook-Id': job.data.webhookId, 'X-Misskey-Hook-Secret': job.data.secret, 'Content-Type': 'application/json', }, body: JSON.stringify({ - server: this.config.url, + server: this.config.webUrl, hookId: job.data.webhookId, eventId: job.data.eventId, createdAt: job.data.createdAt, diff --git a/packages/backend/src/queue/processors/UserWebhookDeliverProcessorService.ts b/packages/backend/src/queue/processors/UserWebhookDeliverProcessorService.ts index 9ec630ef70..3d764125af 100644 --- a/packages/backend/src/queue/processors/UserWebhookDeliverProcessorService.ts +++ b/packages/backend/src/queue/processors/UserWebhookDeliverProcessorService.ts @@ -41,13 +41,13 @@ export class UserWebhookDeliverProcessorService { method: 'POST', headers: { 'User-Agent': 'Misskey-Hooks', - 'X-Misskey-Host': this.config.host, + 'X-Misskey-Host': this.config.webHost, 'X-Misskey-Hook-Id': job.data.webhookId, 'X-Misskey-Hook-Secret': job.data.secret, 'Content-Type': 'application/json', }, body: JSON.stringify({ - server: this.config.url, + server: this.config.webUrl, hookId: job.data.webhookId, userId: job.data.userId, eventId: job.data.eventId, diff --git a/packages/backend/src/server/ActivityPubServerService.ts b/packages/backend/src/server/ActivityPubServerService.ts index 54ffeecc6b..8e582eafa4 100644 --- a/packages/backend/src/server/ActivityPubServerService.ts +++ b/packages/backend/src/server/ActivityPubServerService.ts @@ -99,7 +99,7 @@ export class ActivityPubServerService { private async packActivity(note: MiNote): Promise<any> { if (isRenote(note) && !isQuote(note)) { const renote = await this.notesRepository.findOneByOrFail({ id: note.renoteId }); - return this.apRendererService.renderAnnounce(renote.uri ? renote.uri : `${this.config.url}/notes/${renote.id}`, note); + return this.apRendererService.renderAnnounce(renote.uri ? renote.uri : `${this.config.webUrl}/notes/${renote.id}`, note); } return this.apRendererService.renderCreate(await this.apRendererService.renderNote(note, false), note); @@ -122,7 +122,7 @@ export class ActivityPubServerService { } if (signature.params.headers.indexOf('host') === -1 - || request.headers.host !== this.config.host) { + || (request.headers.host !== this.config.localHost && request.headers.host !== this.config.webHost)) { // Host not specified or not match. reply.code(401); return; @@ -223,7 +223,7 @@ export class ActivityPubServerService { //#endregion const limit = 10; - const partOf = `${this.config.url}/users/${userId}/followers`; + const partOf = `${this.config.webUrl}/users/${userId}/followers`; if (page) { const query = { @@ -320,7 +320,7 @@ export class ActivityPubServerService { //#endregion const limit = 10; - const partOf = `${this.config.url}/users/${userId}/following`; + const partOf = `${this.config.webUrl}/users/${userId}/following`; if (page) { const query = { @@ -403,7 +403,7 @@ export class ActivityPubServerService { const renderedNotes = await Promise.all(pinnedNotes.map(note => this.apRendererService.renderNote(note))); const rendered = this.apRendererService.renderOrderedCollection( - `${this.config.url}/users/${userId}/collections/featured`, + `${this.config.webUrl}/users/${userId}/collections/featured`, renderedNotes.length, undefined, undefined, @@ -460,7 +460,7 @@ export class ActivityPubServerService { } const limit = 20; - const partOf = `${this.config.url}/users/${userId}/outbox`; + const partOf = `${this.config.webUrl}/users/${userId}/outbox`; if (page) { const notes = this.meta.enableFanoutTimeline ? await this.fanoutTimelineEndpointService.getMiNotes({ diff --git a/packages/backend/src/server/FileServerService.ts b/packages/backend/src/server/FileServerService.ts index f5034d0733..249c4f33cc 100644 --- a/packages/backend/src/server/FileServerService.ts +++ b/packages/backend/src/server/FileServerService.ts @@ -98,7 +98,7 @@ export class FileServerService { .catch(err => this.errorHandler(request, reply, err)); }); fastify.get<{ Params: { key: string; } }>('/files/:key/*', async (request, reply) => { - return await reply.redirect(`${this.config.url}/files/${request.params.key}`, 301); + return await reply.redirect(`${this.config.webUrl}/files/${request.params.key}`, 301); }); done(); }); diff --git a/packages/backend/src/server/NodeinfoServerService.ts b/packages/backend/src/server/NodeinfoServerService.ts index 93c36f5365..69afa9bb77 100644 --- a/packages/backend/src/server/NodeinfoServerService.ts +++ b/packages/backend/src/server/NodeinfoServerService.ts @@ -38,10 +38,10 @@ export class NodeinfoServerService { public getLinks() { return [{ rel: 'http://nodeinfo.diaspora.software/ns/schema/2.1', - href: this.config.url + nodeinfo2_1path, + href: this.config.webUrl + nodeinfo2_1path, }, { rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0', - href: this.config.url + nodeinfo2_0path, + href: this.config.webUrl + nodeinfo2_0path, }]; } diff --git a/packages/backend/src/server/ServerService.ts b/packages/backend/src/server/ServerService.ts index ef9ac81f95..5c11e1012a 100644 --- a/packages/backend/src/server/ServerService.ts +++ b/packages/backend/src/server/ServerService.ts @@ -82,7 +82,7 @@ export class ServerService implements OnApplicationShutdown { // HSTS // 6months (15552000sec) - if (this.config.url.startsWith('https') && !this.config.disableHsts) { + if (this.config.webUrl.startsWith('https') && !this.config.disableHsts) { fastify.addHook('onRequest', (request, reply, done) => { reply.header('strict-transport-security', 'max-age=15552000; preload'); done(); @@ -123,7 +123,7 @@ export class ServerService implements OnApplicationShutdown { } const effectiveLocation = process.env.NODE_ENV === 'production' ? location : location.replace(/^http:\/\//, 'https://'); - if (effectiveLocation.startsWith(`https://${this.config.host}/`)) { + if (effectiveLocation.startsWith(`https://${this.config.webHost}/`)) { done(); return; } @@ -213,7 +213,7 @@ export class ServerService implements OnApplicationShutdown { const user = await this.usersRepository.findOne({ where: { usernameLower: username.toLowerCase(), - host: (host == null) || (host === this.config.host) ? IsNull() : host, + host: (host == null) || (host === this.config.localHost) ? IsNull() : host, isSuspended: false, }, }); diff --git a/packages/backend/src/server/WellKnownServerService.ts b/packages/backend/src/server/WellKnownServerService.ts index ebfd1a421d..2f99ed0ee0 100644 --- a/packages/backend/src/server/WellKnownServerService.ts +++ b/packages/backend/src/server/WellKnownServerService.ts @@ -78,7 +78,7 @@ export class WellKnownServerService { return XRD({ element: 'Link', attributes: { rel: 'lrdd', type: xrd, - template: `${this.config.url}${webFingerPath}?resource={uri}`, + template: `${this.config.webUrl}${webFingerPath}?resource={uri}`, } }); }); @@ -93,7 +93,7 @@ export class WellKnownServerService { links: [{ rel: 'lrdd', type: jrd, - template: `${this.config.url}${webFingerPath}?resource={uri}`, + template: `${this.config.webUrl}${webFingerPath}?resource={uri}`, }], }; }); @@ -129,15 +129,15 @@ fastify.get('/.well-known/change-password', async (request, reply) => { }); const generateQuery = (resource: string): FindOptionsWhere<MiUser> | number => - resource.startsWith(`${this.config.url.toLowerCase()}/users/`) ? + resource.startsWith(`${this.config.webUrl.toLowerCase()}/users/`) ? fromId(resource.split('/').pop()!) : fromAcct(Acct.parse( - resource.startsWith(`${this.config.url.toLowerCase()}/@`) ? resource.split('/').pop()! : + resource.startsWith(`${this.config.webUrl.toLowerCase()}/@`) ? resource.split('/').pop()! : resource.startsWith('acct:') ? resource.slice('acct:'.length) : resource)); const fromAcct = (acct: Acct.Acct): FindOptionsWhere<MiUser> | number => - !acct.host || acct.host === this.config.host.toLowerCase() ? { + !acct.host || acct.host === this.config.localHost.toLowerCase() ? { usernameLower: acct.username.toLowerCase(), host: IsNull(), isSuspended: false, @@ -162,7 +162,7 @@ fastify.get('/.well-known/change-password', async (request, reply) => { return; } - const subject = `acct:${user.username}@${this.config.host}`; + const subject = `acct:${user.username}@${this.config.localHost}`; const self = { rel: 'self', type: 'application/activity+json', @@ -171,11 +171,11 @@ fastify.get('/.well-known/change-password', async (request, reply) => { const profilePage = { rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', - href: `${this.config.url}/@${user.username}`, + href: `${this.config.webUrl}/@${user.username}`, }; const subscribe = { rel: 'http://ostatus.org/schema/1.0/subscribe', - template: `${this.config.url}/authorize-follow?acct={uri}`, + template: `${this.config.webUrl}/authorize-follow?acct={uri}`, }; vary(reply.raw, 'Accept'); diff --git a/packages/backend/src/server/api/SigninApiService.ts b/packages/backend/src/server/api/SigninApiService.ts index 5c9d16a95a..2e40743b62 100644 --- a/packages/backend/src/server/api/SigninApiService.ts +++ b/packages/backend/src/server/api/SigninApiService.ts @@ -82,7 +82,7 @@ export class SigninApiService { }>, reply: FastifyReply, ) { - reply.header('Access-Control-Allow-Origin', this.config.url); + reply.header('Access-Control-Allow-Origin', this.config.webUrl); reply.header('Access-Control-Allow-Credentials', 'true'); const body = request.body; diff --git a/packages/backend/src/server/api/SigninWithPasskeyApiService.ts b/packages/backend/src/server/api/SigninWithPasskeyApiService.ts index 6feb4c3afa..b4386fba7e 100644 --- a/packages/backend/src/server/api/SigninWithPasskeyApiService.ts +++ b/packages/backend/src/server/api/SigninWithPasskeyApiService.ts @@ -61,7 +61,7 @@ export class SigninWithPasskeyApiService { }>, reply: FastifyReply, ) { - reply.header('Access-Control-Allow-Origin', this.config.url); + reply.header('Access-Control-Allow-Origin', this.config.webUrl); reply.header('Access-Control-Allow-Credentials', 'true'); const body = request.body; diff --git a/packages/backend/src/server/api/SignupApiService.ts b/packages/backend/src/server/api/SignupApiService.ts index b419c51ef1..bfdf8859a7 100644 --- a/packages/backend/src/server/api/SignupApiService.ts +++ b/packages/backend/src/server/api/SignupApiService.ts @@ -198,7 +198,7 @@ export class SignupApiService { password: hash, }); - const link = `${this.config.url}/signup-complete/${code}`; + const link = `${this.config.webUrl}/signup-complete/${code}`; this.emailService.sendEmail(emailAddress!, 'Signup', `To complete signup, please click this link:<br><a href="${link}">${link}</a>`, diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index 5beed3a7e8..20897c1af1 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -627,7 +627,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- version: this.config.version, name: instance.name, shortName: instance.shortName, - uri: this.config.url, + uri: this.config.webUrl, description: instance.description, langs: instance.langs, tosUrl: instance.termsOfServiceUrl, diff --git a/packages/backend/src/server/api/endpoints/i/2fa/register.ts b/packages/backend/src/server/api/endpoints/i/2fa/register.ts index b6c837eda7..7699063288 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/register.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/register.ts @@ -94,7 +94,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- secret, digits: 6, label: me.username, - issuer: this.config.host, + issuer: this.config.webHost, }); const url = totp.toString(); const qr = await QRCode.toDataURL(url); @@ -104,7 +104,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- url, secret: secret.base32, label: me.username, - issuer: this.config.host, + issuer: this.config.webHost, }; }); } diff --git a/packages/backend/src/server/api/endpoints/i/update-email.ts b/packages/backend/src/server/api/endpoints/i/update-email.ts index c2f4281f36..620f854373 100644 --- a/packages/backend/src/server/api/endpoints/i/update-email.ts +++ b/packages/backend/src/server/api/endpoints/i/update-email.ts @@ -131,7 +131,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- emailVerifyCode: code, }); - const link = `${this.config.url}/verify-email/${code}`; + const link = `${this.config.webUrl}/verify-email/${code}`; this.emailService.sendEmail(ps.email, 'Email verification', `To verify email, please click this link:<br><a href="${link}">${link}</a>`, diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index 5207d9f2b0..2b84d67e7c 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -571,7 +571,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- const doc = htmlParser.parse(html); - const myLink = `${this.config.url}/@${user.username}`; + const myLink = `${this.config.webUrl}/@${user.username}`; const aEls = Array.from(doc.getElementsByTagName('a')); const linkEls = Array.from(doc.getElementsByTagName('link')); diff --git a/packages/backend/src/server/api/endpoints/request-reset-password.ts b/packages/backend/src/server/api/endpoints/request-reset-password.ts index 86fe6a2e6e..9f4acec44e 100644 --- a/packages/backend/src/server/api/endpoints/request-reset-password.ts +++ b/packages/backend/src/server/api/endpoints/request-reset-password.ts @@ -89,7 +89,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- token, }); - const link = `${this.config.url}/reset-password/${token}`; + const link = `${this.config.webUrl}/reset-password/${token}`; this.emailService.sendEmail(ps.email, 'Password reset requested', `To reset password, please click this link:<br><a href="${link}">${link}</a>`, diff --git a/packages/backend/src/server/file/FileServerProxyHandler.ts b/packages/backend/src/server/file/FileServerProxyHandler.ts index 41e8e47ba5..c606d54891 100644 --- a/packages/backend/src/server/file/FileServerProxyHandler.ts +++ b/packages/backend/src/server/file/FileServerProxyHandler.ts @@ -260,8 +260,8 @@ export class FileServerProxyHandler { } private async getStreamAndTypeFromUrl(url: string): Promise<ProxySource> { - if (url.startsWith(`${this.config.url}/files/`)) { - const key = url.replace(`${this.config.url}/files/`, '').split('/').shift(); + if (url.startsWith(`${this.config.webUrl}/files/`)) { + const key = url.replace(`${this.config.webUrl}/files/`, '').split('/').shift(); if (!key) throw new StatusError('Invalid File Key', 400, 'Invalid File Key'); return await this.fileResolver.resolveFileByAccessKey(key); diff --git a/packages/backend/src/server/oauth/OAuth2ProviderService.ts b/packages/backend/src/server/oauth/OAuth2ProviderService.ts index 840c34b806..2682aeace8 100644 --- a/packages/backend/src/server/oauth/OAuth2ProviderService.ts +++ b/packages/backend/src/server/oauth/OAuth2ProviderService.ts @@ -341,7 +341,7 @@ export class OAuth2ProviderService { // "Authorization servers MUST support PKCE [RFC7636]." this.#server.grant(oauth2Pkce.extensions()); this.#server.grant(oauth2orize.grant.code({ - modes: getQueryMode(config.url), + modes: getQueryMode(config.webUrl), }, (client, redirectUri, token, ares, areq, locals, done) => { (async (): Promise<OmitFirstElement<Parameters<typeof done>>> => { this.#logger.info(`Checking the user before sending authorization code to ${client.id}`); @@ -431,9 +431,9 @@ export class OAuth2ProviderService { // https://indieauth.spec.indieweb.org/#indieauth-server-metadata public generateRFC8414() { return { - issuer: this.config.url, - authorization_endpoint: new URL('/oauth/authorize', this.config.url), - token_endpoint: new URL('/oauth/token', this.config.url), + issuer: this.config.webUrl, + authorization_endpoint: new URL('/oauth/authorize', this.config.webUrl), + token_endpoint: new URL('/oauth/token', this.config.webUrl), scopes_supported: kinds, response_types_supported: ['code'], grant_types_supported: ['authorization_code'], @@ -521,7 +521,7 @@ export class OAuth2ProviderService { }) as ValidateFunctionArity2)); fastify.use('/authorize', this.#server.errorHandler({ mode: 'indirect', - modes: getQueryMode(this.config.url), + modes: getQueryMode(this.config.webUrl), })); fastify.use('/authorize', this.#server.errorHandler()); diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts index 24bc619e79..ea567a53f2 100644 --- a/packages/backend/src/server/web/ClientServerService.ts +++ b/packages/backend/src/server/web/ClientServerService.ts @@ -156,10 +156,10 @@ export class ClientServerService { let manifest = { // 空文字列の場合右辺を使いたいため // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - 'short_name': this.meta.shortName || this.meta.name || this.config.host, + 'short_name': this.meta.shortName || this.meta.name || this.config.webHost, // 空文字列の場合右辺を使いたいため // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - 'name': this.meta.name || this.config.host, + 'name': this.meta.name || this.config.webHost, 'start_url': '/', 'display': 'standalone', 'background_color': '#313a42', @@ -213,7 +213,7 @@ export class ClientServerService { @bindThis public createServer(fastify: FastifyInstance, options: FastifyPluginOptions, done: (err?: Error) => void) { - const configUrl = new URL(this.config.url); + const configUrl = new URL(this.config.webUrl); fastify.addHook('onRequest', (request, reply, done) => { // クリックジャッキング防止のためiFrameの中に入れられないようにする @@ -407,8 +407,8 @@ export class ClientServerService { content += `<ShortName>${name}</ShortName>`; content += `<Description>${name} Search</Description>`; content += '<InputEncoding>UTF-8</InputEncoding>'; - content += `<Image width="16" height="16" type="image/x-icon">${this.config.url}/favicon.ico</Image>`; - content += `<Url type="text/html" template="${this.config.url}/search?q={searchTerms}"/>`; + content += `<Image width="16" height="16" type="image/x-icon">${this.config.webUrl}/favicon.ico</Image>`; + content += `<Url type="text/html" template="${this.config.webUrl}/search?q={searchTerms}"/>`; content += '</OpenSearchDescription>'; reply.header('Content-Type', 'application/opensearchdescription+xml'); diff --git a/packages/backend/src/server/web/FeedService.ts b/packages/backend/src/server/web/FeedService.ts index eae7645321..9c386d3a4f 100644 --- a/packages/backend/src/server/web/FeedService.ts +++ b/packages/backend/src/server/web/FeedService.ts @@ -42,7 +42,7 @@ export class FeedService { @bindThis public async packFeed(user: MiUser) { const author = { - link: `${this.config.url}/@${user.username}`, + link: `${this.config.webUrl}/@${user.username}`, name: user.name ?? user.username, }; @@ -60,7 +60,7 @@ export class FeedService { const feed = new Feed({ id: author.link, - title: `${author.name} (@${user.username}@${this.config.host})`, + title: `${author.name} (@${user.username}@${this.config.localHost})`, updated: notes.length !== 0 ? this.idService.parse(notes[0].id).date : undefined, generator: 'Misskey', description: `${user.notesCount} Notes, ${profile.followingVisibility === 'public' ? user.followingCount : '?'} Following, ${profile.followersVisibility === 'public' ? user.followersCount : '?'} Followers${profile.description ? ` · ${profile.description}` : ''}`, @@ -83,7 +83,7 @@ export class FeedService { feed.addItem({ title: `New note by ${author.name}`, - link: `${this.config.url}/notes/${note.id}`, + link: `${this.config.webUrl}/notes/${note.id}`, date: this.idService.parse(note.id).date, description: note.cw ?? undefined, content: text ? this.mfmService.toHtml(mfmParse(text), JSON.parse(note.mentionedRemoteUsers)) ?? undefined : undefined, diff --git a/packages/backend/src/server/web/HtmlTemplateService.ts b/packages/backend/src/server/web/HtmlTemplateService.ts index 8ff985530d..ffb8f7df9f 100644 --- a/packages/backend/src/server/web/HtmlTemplateService.ts +++ b/packages/backend/src/server/web/HtmlTemplateService.ts @@ -86,7 +86,8 @@ export class HtmlTemplateService { serverErrorImageUrl: this.meta.serverErrorImageUrl ?? 'https://xn--931a.moe/assets/error.jpg', infoImageUrl: this.meta.infoImageUrl ?? 'https://xn--931a.moe/assets/info.jpg', notFoundImageUrl: this.meta.notFoundImageUrl ?? 'https://xn--931a.moe/assets/not-found.jpg', - instanceUrl: this.config.url, + instanceUrl: this.config.webUrl, + localUrl: this.config.localUrl, metaJson: htmlSafeJsonStringify(await this.metaEntityService.packDetailed(this.meta)), now: Date.now(), federationEnabled: this.meta.federation !== 'none', diff --git a/packages/backend/src/server/web/views/_.ts b/packages/backend/src/server/web/views/_.ts index ac7418f362..7476c218a9 100644 --- a/packages/backend/src/server/web/views/_.ts +++ b/packages/backend/src/server/web/views/_.ts @@ -34,6 +34,7 @@ export type CommonData = MinimumCommonData & { infoImageUrl: string; notFoundImageUrl: string; instanceUrl: string; + localUrl: string; now: number; federationEnabled: boolean; frontendBootloaderJs: string | null; diff --git a/packages/backend/src/server/web/views/announcement.tsx b/packages/backend/src/server/web/views/announcement.tsx index bc1c808177..70105732a5 100644 --- a/packages/backend/src/server/web/views/announcement.tsx +++ b/packages/backend/src/server/web/views/announcement.tsx @@ -18,7 +18,7 @@ export function AnnouncementPage(props: CommonProps<{ <meta property="og:type" content="article" /> <meta property="og:title" content={props.announcement.title} /> <meta property="og:description" content={description} /> - <meta property="og:url" content={`${props.config.url}/announcements/${props.announcement.id}`} /> + <meta property="og:url" content={`${props.config.webUrl}/announcements/${props.announcement.id}`} /> {props.announcement.imageUrl ? ( <> <meta property="og:image" content={props.announcement.imageUrl} /> diff --git a/packages/backend/src/server/web/views/base-embed.tsx b/packages/backend/src/server/web/views/base-embed.tsx index 011b66592e..6de70152b6 100644 --- a/packages/backend/src/server/web/views/base-embed.tsx +++ b/packages/backend/src/server/web/views/base-embed.tsx @@ -41,6 +41,7 @@ export function BaseEmbed(props: PropsWithChildren<CommonProps<{ <meta name="theme-color-orig" content={props.themeColor ?? '#86b300'} /> <meta property="og:site_name" content={props.instanceName || 'Misskey'} /> <meta property="instance_url" content={props.instanceUrl} /> + <meta property="local_url" content={props.localUrl} /> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover" /> <meta name="format-detection" content="telephone=no,date=no,address=no,email=no,url=no" /> <link rel="icon" href={props.icon ?? '/favicon.ico'} /> diff --git a/packages/backend/src/server/web/views/base.tsx b/packages/backend/src/server/web/views/base.tsx index 6fa3395fb8..59dcc27f1e 100644 --- a/packages/backend/src/server/web/views/base.tsx +++ b/packages/backend/src/server/web/views/base.tsx @@ -43,12 +43,13 @@ export function Layout(props: PropsWithChildren<CommonProps<{ <meta name="theme-color-orig" content={props.themeColor ?? '#86b300'} /> <meta property="og:site_name" content={props.instanceName || 'Misskey'} /> <meta property="instance_url" content={props.instanceUrl} /> + <meta property="local_url" content={props.localUrl} /> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover" /> <meta name="format-detection" content="telephone=no,date=no,address=no,email=no,url=no" /> <link rel="icon" href={props.icon || '/favicon.ico'} /> <link rel="apple-touch-icon" href={props.appleTouchIcon || '/apple-touch-icon.png'} /> <link rel="manifest" href="/manifest.json" /> - <link rel="search" type="application/opensearchdescription+xml" title={props.title || 'Misskey'} href={`${props.config.url}/opensearch.xml`} /> + <link rel="search" type="application/opensearchdescription+xml" title={props.title || 'Misskey'} href={`${props.config.webUrl}/opensearch.xml`} /> {props.serverErrorImageUrl != null ? <link rel="prefetch" as="image" href={props.serverErrorImageUrl} /> : null} {props.infoImageUrl != null ? <link rel="prefetch" as="image" href={props.infoImageUrl} /> : null} {props.notFoundImageUrl != null ? <link rel="prefetch" as="image" href={props.notFoundImageUrl} /> : null} diff --git a/packages/backend/src/server/web/views/channel.tsx b/packages/backend/src/server/web/views/channel.tsx index 7d8123ea85..9bbf2c6a15 100644 --- a/packages/backend/src/server/web/views/channel.tsx +++ b/packages/backend/src/server/web/views/channel.tsx @@ -17,7 +17,7 @@ export function ChannelPage(props: CommonProps<{ <meta property="og:type" content="website" /> <meta property="og:title" content={props.channel.name} /> {props.channel.description != null ? <meta property="og:description" content={props.channel.description} /> : null} - <meta property="og:url" content={`${props.config.url}/channels/${props.channel.id}`} /> + <meta property="og:url" content={`${props.config.webUrl}/channels/${props.channel.id}`} /> {props.channel.bannerUrl ? ( <> <meta property="og:image" content={props.channel.bannerUrl} /> diff --git a/packages/backend/src/server/web/views/clip.tsx b/packages/backend/src/server/web/views/clip.tsx index c3cc505e35..208ed176d8 100644 --- a/packages/backend/src/server/web/views/clip.tsx +++ b/packages/backend/src/server/web/views/clip.tsx @@ -18,7 +18,7 @@ export function ClipPage(props: CommonProps<{ <meta property="og:type" content="article" /> <meta property="og:title" content={props.clip.name} /> {props.clip.description != null ? <meta property="og:description" content={props.clip.description} /> : null} - <meta property="og:url" content={`${props.config.url}/clips/${props.clip.id}`} /> + <meta property="og:url" content={`${props.config.webUrl}/clips/${props.clip.id}`} /> {props.clip.user.avatarUrl ? ( <> <meta property="og:image" content={props.clip.user.avatarUrl} /> diff --git a/packages/backend/src/server/web/views/flash.tsx b/packages/backend/src/server/web/views/flash.tsx index 25a6b2c0ae..6942bcd5e0 100644 --- a/packages/backend/src/server/web/views/flash.tsx +++ b/packages/backend/src/server/web/views/flash.tsx @@ -18,7 +18,7 @@ export function FlashPage(props: CommonProps<{ <meta property="og:type" content="article" /> <meta property="og:title" content={props.flash.title} /> <meta property="og:description" content={props.flash.summary} /> - <meta property="og:url" content={`${props.config.url}/play/${props.flash.id}`} /> + <meta property="og:url" content={`${props.config.webUrl}/play/${props.flash.id}`} /> {props.flash.user.avatarUrl ? ( <> <meta property="og:image" content={props.flash.user.avatarUrl} /> diff --git a/packages/backend/src/server/web/views/gallery-post.tsx b/packages/backend/src/server/web/views/gallery-post.tsx index 2bec2de930..3528dc9a20 100644 --- a/packages/backend/src/server/web/views/gallery-post.tsx +++ b/packages/backend/src/server/web/views/gallery-post.tsx @@ -18,7 +18,7 @@ export function GalleryPostPage(props: CommonProps<{ <meta property="og:type" content="article" /> <meta property="og:title" content={props.galleryPost.title} /> {props.galleryPost.description != null ? <meta property="og:description" content={props.galleryPost.description} /> : null} - <meta property="og:url" content={`${props.config.url}/gallery/${props.galleryPost.id}`} /> + <meta property="og:url" content={`${props.config.webUrl}/gallery/${props.galleryPost.id}`} /> {props.galleryPost.isSensitive && props.galleryPost.user.avatarUrl ? ( <> <meta property="og:image" content={props.galleryPost.user.avatarUrl} /> diff --git a/packages/backend/src/server/web/views/info-card.tsx b/packages/backend/src/server/web/views/info-card.tsx index 27be4c69e8..bcc28a5110 100644 --- a/packages/backend/src/server/web/views/info-card.tsx +++ b/packages/backend/src/server/web/views/info-card.tsx @@ -21,13 +21,13 @@ export function InfoCardPage(props: CommonPropsMinimum<{ <meta charset="UTF-8" /> <meta name="application-name" content="Misskey" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <title safe>{props.meta.name ?? props.config.url}</title> + <title safe>{props.meta.name ?? props.config.webUrl}</title> <link rel="stylesheet" href="/static-assets/misc/info-card.css" /> </head> <body> - <a id="a" href={props.config.url} target="_blank" rel="noopener noreferrer"> + <a id="a" href={props.config.webUrl} target="_blank" rel="noopener noreferrer"> <header id="banner" style={props.meta.bannerUrl != null ? `background-image: url(${props.meta.bannerUrl});` : ''}> - <div id="title" safe>{props.meta.name ?? props.config.url}</div> + <div id="title" safe>{props.meta.name ?? props.config.webUrl}</div> </header> </a> <div id="content"> diff --git a/packages/backend/src/server/web/views/note.tsx b/packages/backend/src/server/web/views/note.tsx index 803c3d2537..85657eb1ed 100644 --- a/packages/backend/src/server/web/views/note.tsx +++ b/packages/backend/src/server/web/views/note.tsx @@ -26,7 +26,7 @@ export function NotePage(props: CommonProps<{ <meta property="og:type" content="article" /> <meta property="og:title" content={title} /> <meta property="og:description" content={summary} /> - <meta property="og:url" content={`${props.config.url}/notes/${props.note.id}`} /> + <meta property="og:url" content={`${props.config.webUrl}/notes/${props.note.id}`} /> {videos.map(video => ( <> <meta property="og:video:url" content={video.url} /> @@ -74,7 +74,7 @@ export function NotePage(props: CommonProps<{ {props.federationEnabled ? ( <> - {props.note.user.host == null ? <link rel="alternate" type="application/activity+json" href={`${props.config.url}/notes/${props.note.id}`} /> : null} + {props.note.user.host == null ? <link rel="alternate" type="application/activity+json" href={`${props.config.webUrl}/notes/${props.note.id}`} /> : null} {props.note.uri != null ? <link rel="alternate" type="application/activity+json" href={props.note.uri} /> : null} </> ) : null} diff --git a/packages/backend/src/server/web/views/page.tsx b/packages/backend/src/server/web/views/page.tsx index d0484612df..f523173a49 100644 --- a/packages/backend/src/server/web/views/page.tsx +++ b/packages/backend/src/server/web/views/page.tsx @@ -18,7 +18,7 @@ export function PagePage(props: CommonProps<{ <meta property="og:type" content="article" /> <meta property="og:title" content={props.page.title} /> {props.page.summary != null ? <meta property="og:description" content={props.page.summary} /> : null} - <meta property="og:url" content={`${props.config.url}/pages/${props.page.id}`} /> + <meta property="og:url" content={`${props.config.webUrl}/pages/${props.page.id}`} /> {props.page.eyeCatchingImage != null ? ( <> <meta property="og:image" content={props.page.eyeCatchingImage.thumbnailUrl ?? props.page.eyeCatchingImage.url} /> diff --git a/packages/backend/src/server/web/views/reversi-game.tsx b/packages/backend/src/server/web/views/reversi-game.tsx index 22609311fd..d969b47575 100644 --- a/packages/backend/src/server/web/views/reversi-game.tsx +++ b/packages/backend/src/server/web/views/reversi-game.tsx @@ -19,7 +19,7 @@ export function ReversiGamePage(props: CommonProps<{ <meta property="og:type" content="article" /> <meta property="og:title" content={title} /> <meta property="og:description" content={description} /> - <meta property="og:url" content={`${props.config.url}/reversi/g/${props.reversiGame.id}`} /> + <meta property="og:url" content={`${props.config.webUrl}/reversi/g/${props.reversiGame.id}`} /> <meta property="twitter:card" content="summary" /> </> ); diff --git a/packages/backend/src/server/web/views/user.tsx b/packages/backend/src/server/web/views/user.tsx index 76c2633ab9..023af2fdd0 100644 --- a/packages/backend/src/server/web/views/user.tsx +++ b/packages/backend/src/server/web/views/user.tsx @@ -26,7 +26,7 @@ export function UserPage(props: CommonProps<{ <meta property="og:type" content="blog" /> <meta property="og:title" content={title} /> {props.user.description != null ? <meta property="og:description" content={props.user.description} /> : null} - <meta property="og:url" content={`${props.config.url}/@${props.user.username}`} /> + <meta property="og:url" content={`${props.config.webUrl}/@${props.user.username}`} /> <meta property="og:image" content={props.user.avatarUrl} /> <meta property="twitter:card" content="summary" /> </> @@ -48,7 +48,7 @@ export function UserPage(props: CommonProps<{ {props.sub == null && props.federationEnabled ? ( <> - {props.user.host == null ? <link rel="alternate" type="application/activity+json" href={`${props.config.url}/users/${props.user.id}`} /> : null} + {props.user.host == null ? <link rel="alternate" type="application/activity+json" href={`${props.config.webUrl}/users/${props.user.id}`} /> : null} {props.user.uri != null ? <link rel="alternate" type="application/activity+json" href={props.user.uri} /> : null} {props.profile.url != null ? <link rel="alternate" type="text/html" href={props.profile.url} /> : null} </> |