Using Netlify's hosted Identity service with self-hosted Netlify CMS
Asked Answered
T

1

5

I am hosting my website on my own server, and using Netlify CMS. However, I would still like to use Netlify's hosted Identity and Git Gateway services, instead of running my own.

Tetraspore answered 4/9, 2018 at 22:44 Comment(0)
T
8

Yes, that is possible. First, you will need to set up your site in Netlify, and make sure you have the Identity and Git Gateway services turned on and configured. Follow the regular "Add to Your Site" setup for Netlify CMS, but make these changes:

CMS config.yml changes

The backend section of your config should contain the following three keys. Replace my-site.netlify.com with your Netlify site URL.

backend:
  name: git-gateway
  identity_url: "https://my-site.netlify.com/.netlify/identity"
  gateway_url: "https://my-site.netlify.com/.netlify/git"

CMS index.html changes

Assuming you already have the Netlify Identity script added (netlify-identity-widget.js), remove it and use the netlify-identity.js script from the same package instead. This script will not initialize automatically, which allows us to set our own parameters. Do this on both your admin page and your site homepage.

<script src="https://identity.netlify.com/v1/netlify-identity.js"></script>

Next, add this script right below it, on both the admin page and the home page. Again, replace my-netlify-site.com with your Netlify site URL.

<script>
  if (document.readyState === "loading") {
    document.addEventListener("DOMContentLoaded", function () {
      netlifyIdentity.init({
        APIUrl: "https://my-site.netlify.com/.netlify/identity"
      });
    });
  } else {
    netlifyIdentity.init({
      APIUrl: "https://my-site.netlify.com/.netlify/identity"
    });
  }
</script>
Tetraspore answered 4/9, 2018 at 22:44 Comment(1)
I don't know how the heck you figured this out but thank you.Children

© 2022 - 2024 — McMap. All rights reserved.