question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CMS Manual Initialization is not working

See original GitHub issue

Describe 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:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
erezrokahcommented, Jan 29, 2020

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

0reactions
mushkin-vcommented, Jan 29, 2020

@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:

aws s3 cp s3://mysite-master/ s3://mysite-master/ --exclude ‘’ --include '.yml’ --no-guess-mime-type --content-type="text/yaml" --metadata-directive="REPLACE" --recursive

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DRY Netlify CMS config with Manual Initialization
To use Netlify CMS with manual initialization, you also need to set up the general CMS settings.
Read more >
Environment variables in Netflify CMS manual initialization ...
I'm manually initializing the Netlify CMS in an index.js to change the branch on which it pushes depending on an environment variable.
Read more >
Manual Initialization in Nuxt + Netlify CMS project?
I'm trying to enable manual initialization so I can better organize my config files. This is what I currently have in admin/index.html:
Read more >
Episerver Initialization Module
How To Debug An Episerver Scheduled Job or Initialization Module ... Issues With The HTTPContext Url Doesn't Set Episerver Initialization Module.
Read more >
Beta Features!
You can connect Netlify CMS to a local Git repository, instead of working with ... the netlify-cms package installed to your project, manual...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found