I’m trying to setup the preview mode in my app but I keep getting the same error even though I’m following the official documentation:
{
sys: { type: 'Error', id: 'AccessTokenInvalid' },
message: 'The access token you sent could not be found or is invalid.',
requestId: ...
}
I currently have only one API Key enable and one Contenful project. I tried copying the preview token multiple times but it doesn’t seem to be the problem. With the following logic, the Delivery API works but the Preview API gives me the error:
this.client = createClient({
space: process.env.CONTENTFUL_SPACE,
accessToken: preview
? process.env.CONTENTFUL_PREVIEW_TOKEN
: process.env.CONTENTFUL_TOKEN,
environment: process.env.CONTENTFUL_ENV,
host: preview ? "https://preview.contentful.com" : "https://cdn.contentful.com",
});