Version Migration

Follow this guide to migrate between Kirby Headless versions.

Migrating from v5 to v6

CORS Configuration Changes

Breaking Change: Kirby Headless v6 removes custom CORS handling in favor of Kirby's native CORS support (Kirby 5.2.0+).

If you were using headless.cors configuration in v5, migrate to Kirby's native cors option:

Before (v5):

config.php
return [
    'headless' => [
        'cors' => [
            'allowOrigin' => '*',
            'allowMethods' => 'GET, POST, OPTIONS',
            'allowHeaders' => 'Accept, Content-Type, Authorization, X-Language, X-Cacheable',
            'maxAge' => '86400'
        ]
    ]
];

After (v6):

config.php
return [
    'cors' => [
        'allowOrigin' => '*',
        'allowMethods' => ['GET', 'POST'],
        'allowHeaders' => ['Accept', 'Content-Type', 'Authorization', 'X-Language', 'X-Cacheable'],
        'maxAge' => 86400
    ]
];
Note that allowMethods and allowHeaders now accept arrays instead of comma-separated strings, and maxAge accepts an integer instead of a string. The OPTIONS method is handled automatically by Kirby.

Requirements:

  • Kirby 5.2.0 or higher
  • See the CORS Configuration page for detailed setup instructions and examples.

Migrating from v3 to v4

Kirby Headless v4 contains a breaking change: the result of the toResolvedBlocks() field method has changed. Before, the resolved blocks fields were nested within the resolved key. Now the resolved fields overwrite the original fields. This results in less duplication and a cleaner structure.

Update your frontend code to reflect this change. For example, instead of accessing the resolved key like block.content.resolved.image[0], you can now access the resolved field directly like block.content.image[0].

Resolved Key

If you do not want to update your frontend code, you can still update to v4 and use the old structure by defining a resolvedKey in your config.php:

config.php
return [
    'blocksResolver' => [
        'resolvedKey' => 'resolved'
    ]
];