- Changed STRAPI_URL from https://cms.placebo.mk to http://cms:1337 - Added cms dependency to backend service - This fixes Gateway Timeout errors when backend tries to fetch from Strapi - Enables proper container-to-container communication
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
/**
|
|
* Script to create an API token for backend integration
|
|
* Run this inside the CMS container if the UI doesn't work
|
|
*/
|
|
|
|
import { factories } from '@strapi/strapi';
|
|
|
|
async function createApiToken() {
|
|
const strapi = await factories.createCoreStore()();
|
|
|
|
try {
|
|
// Create API token
|
|
const tokenService = strapi.service('admin::api-token');
|
|
|
|
const token = await tokenService.create({
|
|
name: 'Backend Integration',
|
|
description: 'Token for backend to fetch articles',
|
|
type: 'read-only',
|
|
permissions: [],
|
|
lifespan: null, // Unlimited
|
|
});
|
|
|
|
console.log('✅ API Token created successfully!');
|
|
console.log('\nToken details:');
|
|
console.log('Name:', token.name);
|
|
console.log('Type:', token.type);
|
|
console.log('\nTOKEN (copy this to Coolify as STRAPI_API_TOKEN):');
|
|
console.log(token.accessKey);
|
|
console.log('\n⚠️ Save this token - you won\'t see it again!');
|
|
|
|
} catch (error) {
|
|
console.error('❌ Error creating API token:', error.message);
|
|
} finally {
|
|
await strapi.destroy();
|
|
}
|
|
}
|
|
|
|
createApiToken();
|