diff --git a/core/boot.js b/core/boot.js index 9f6a6e7849..264c8d2d2e 100644 --- a/core/boot.js +++ b/core/boot.js @@ -134,6 +134,9 @@ async function initExpressApps() { async function initServices({config}) { debug('Begin: initServices'); + const defaultApiVersion = config.get('api:versions:default'); + debug(`Default API Version: ${defaultApiVersion}`); + debug('Begin: Dynamic Routing'); // Dynamic routing is generated from the routes.yaml file, which is part of the settings service // When Ghost's DB and core are loaded, we can access this file and call routing.bootstrap.start @@ -170,9 +173,7 @@ async function initServices({config}) { appService.init(), limits.init(), scheduling.init({ - // NOTE: When changing API version need to consider how to migrate custom scheduling adapters - // that rely on URL to lookup persisted scheduled records (jobs, etc.). Ref: https://github.com/TryGhost/Ghost/pull/10726#issuecomment-489557162 - apiUrl: urlUtils.urlFor('api', {version: 'v4', versionType: 'admin'}, true) + apiUrl: urlUtils.urlFor('api', {version: defaultApiVersion, versionType: 'admin'}, true) }) ]); debug('End: Services'); diff --git a/core/shared/config/overrides.json b/core/shared/config/overrides.json index 7809f9b6ba..b26fd6aba5 100644 --- a/core/shared/config/overrides.json +++ b/core/shared/config/overrides.json @@ -62,6 +62,7 @@ "api": { "versions": { "all": ["v2", "v3", "v4", "canary"], + "default": "v4", "canary": { "admin": "canary/admin", "content": "canary/content" diff --git a/core/shared/url-utils.js b/core/shared/url-utils.js index eebe4d7b37..da74e3c015 100644 --- a/core/shared/url-utils.js +++ b/core/shared/url-utils.js @@ -1,13 +1,11 @@ const UrlUtils = require('@tryghost/url-utils'); const config = require('./config'); -const DEFAULT_GHOST_API_VERSION = 'v4'; - const urlUtils = new UrlUtils({ url: config.get('url'), adminUrl: config.get('admin:url'), apiVersions: config.get('api:versions'), - defaultApiVersion: DEFAULT_GHOST_API_VERSION, + defaultApiVersion: config.get('api:versions:default'), slugs: config.get('slugs').protected, redirectCacheMaxAge: config.get('caching:301:maxAge'), baseApiPath: '/ghost/api',