CMS Manual Initialization is not working
See original GitHub issueDescribe the bug I have added manual init for my CMS and now it shows an error when I am trying to open mysite.com/admin/ on my Amazon S3 bucket(locally everything works fine). Error msg:
Error loading the CMS configuration Config Errors: config should have required property ‘collections’ config should have required property ‘media_folder’ config should have required property ‘media_library’ config should match some schema in anyOf Check your config.yml file.
Before manual init everything worked fine. I didn’t add any changes to config.yml and it works great without manual init. I add changes only to my cms.js, now it looks like that:
import CMS from 'netlify-cms-app'
import AboutPagePreview from './preview-templates/AboutPagePreview'
import BlogPostPreview from './preview-templates/BlogPostPreview'
import IndexPagePreview from './preview-templates/IndexPagePreview'
// This global flag enables manual initialization.
window.CMS_MANUAL_INIT = true;
const CMS_BRANCH_DEFAULT = 'develop';
const GATSBY_ACTIVE_ENV_DEFAULT = 'development';
const { CMS_BRANCH } = process.env;
const activeEnv = process.env.GATSBY_ACTIVE_ENV || process.env.NODE_ENV || GATSBY_ACTIVE_ENV_DEFAULT;
const API_ID = activeEnv===GATSBY_ACTIVE_ENV_DEFAULT ? 'secret-code1' : 'secret-code2';
const config = {
backend: {
name: 'bitbucket',
repo: 'my-repo',
auth_type: 'implicit',
branch: CMS_BRANCH || CMS_BRANCH_DEFAULT,
app_id: API_ID,
},
load_config_file: true,
};
CMS.init({ config });
CMS.registerPreviewTemplate('indexpage', IndexPagePreview);
CMS.registerPreviewTemplate('about', AboutPagePreview);
CMS.registerPreviewTemplate('blog', BlogPostPreview);
And I also added manualInit: true to gatsby-config.js:
{
resolve: 'gatsby-plugin-netlify-cms',
options: {
manualInit: true,
modulePath: `${__dirname}/src/cms/cms.js`,
},
},
Expected behavior CMS shows a login page.
Screenshots https://monosnap.com/file/ekysMvPYXGu7CgMUTrcs7lvxAXiIfa
Applicable Versions:
- Netlify CMS version: ^4.1.37
- Git provider: BitBucket
- OS: MacOS
- Browser version: Chrome 79.0.3945.130 (Official Build) (64-bit)
- Deployed to: Amazon S3 bucket
Thanks for the help! PS NetlifyCMS is awesome!
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Oh, thank you for letting us know. I just realized I has to do something similar in the past with AWS S3: https://github.com/erezrokah/gatsby-netlify-cms-aws-test/blob/c3e9d4ed55ee9531b01c50bd201d70afcd0601c1/.circleci/config.yml#L64 but forgotten about it. Closing
@erezrokah @erquhart I have solved my issue. The problem was in a content-type which Amazon S3 sets by default for yml files(Content-Type: binary/octet-stream). I added to my CI/CD pipeline:
And now CMS works fine. S3 returns config.yml with proper content-type text/yaml: https://monosnap.com/file/ybOOvBGVjyBbe2kjITkk4ZB4waO4AN
I was confused in the beginning because without manual init everything was working fine even with this msg in console “Response for config.yml was not yaml (Content-Type: binary/octet-stream).” So I thought this is not important for CMS. It seems that the validation of config.yml for manual and auto init mode works differently. Guys, thanks again for your help! I think you can close this issue.