diff --git a/src/activitypub/index.js b/src/activitypub/index.js index 7320bc0ad7..2142496518 100644 --- a/src/activitypub/index.js +++ b/src/activitypub/index.js @@ -128,7 +128,7 @@ ActivityPub.sign = async (uid, url, payload) => { const date = new Date().toUTCString(); const key = await ActivityPub.getPrivateKey(uid); const userslug = await user.getUserField(uid, 'userslug'); - const keyId = `${nconf.get('url')}${uid > 0 ? `/user/${userslug}` : ''}#key`; + const keyId = `${nconf.get('url')}${uid > 0 ? `/user/${userslug}` : '/actor'}#key`; let digest = null; let headers = '(request-target) host date'; diff --git a/src/controllers/activitypub/actors.js b/src/controllers/activitypub/actors.js index 0e152d15a0..9571d3659b 100644 --- a/src/controllers/activitypub/actors.js +++ b/src/controllers/activitypub/actors.js @@ -17,8 +17,8 @@ Actors.application = async function (req, res) { 'https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1', ], - id: `${nconf.get('url')}`, - url: `${nconf.get('url')}`, + id: `${nconf.get('url')}/actor`, + url: `${nconf.get('url')}/actor`, inbox: `${nconf.get('url')}/inbox`, outbox: `${nconf.get('url')}/outbox`, @@ -27,8 +27,8 @@ Actors.application = async function (req, res) { preferredUsername: nconf.get('url_parsed').hostname, publicKey: { - id: `${nconf.get('url')}#key`, - owner: nconf.get('url'), + id: `${nconf.get('url')}/actor#key`, + owner: `${nconf.get('url')}/actor`, publicKeyPem: publicKey, }, }); diff --git a/src/routes/activitypub.js b/src/routes/activitypub.js index b96e57f83d..1a14a2c7a9 100644 --- a/src/routes/activitypub.js +++ b/src/routes/activitypub.js @@ -14,7 +14,7 @@ module.exports = function (app, middleware, controllers) { const middlewares = [middleware.activitypub.enabled, middleware.activitypub.assertS2S, middleware.exposeUid]; - app.get('/', middlewares, controllers.activitypub.actors.application); + app.get('/actor', middlewares, controllers.activitypub.actors.application); app.get('/user/:userslug', middlewares, controllers.activitypub.actors.user); app.get('/user/:userslug/inbox', middlewares, controllers.activitypub.getInbox); diff --git a/src/routes/index.js b/src/routes/index.js index ed9ad8eb5f..451d68a9fe 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -137,17 +137,17 @@ module.exports = async function (app, middleware) { app.use(middleware.stripLeadingSlashes); - await plugins.reloadRoutes({ router: router }); - await authRoutes.reloadRoutes({ router: router }); - await writeRoutes.reload({ router: router }); - addCoreRoutes(app, router, middleware, mounts); - // handle custom homepage routes router.use('/', controllers.home.rewrite); // homepage handled by `action:homepage.get:[route]` setupPageRoute(router, '/', [], controllers.home.pluginHook); + await plugins.reloadRoutes({ router: router }); + await authRoutes.reloadRoutes({ router: router }); + await writeRoutes.reload({ router: router }); + addCoreRoutes(app, router, middleware, mounts); + winston.info('[router] Routes added'); }; diff --git a/test/activitypub.js b/test/activitypub.js index e6717893aa..e3e196265b 100644 --- a/test/activitypub.js +++ b/test/activitypub.js @@ -221,7 +221,7 @@ describe('ActivityPub integration', () => { let body; before(async () => { - ({ response, body } = await request.get(nconf.get('url'), { + ({ response, body } = await request.get(`${nconf.get('url')}/actor`, { headers: { Accept: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', }, @@ -328,7 +328,7 @@ describe('ActivityPub integration', () => { const [keyId] = signature.split(','); assert(signature); - assert.strictEqual(keyId, `keyId="${nconf.get('url')}#key"`); + assert.strictEqual(keyId, `keyId="${nconf.get('url')}/actor#key"`); }); });