decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.93k stars 3.04k forks source link

Cannot get local netlify-api backend to work #425

Closed onedrawingperday closed 7 years ago

onedrawingperday commented 7 years ago

Hello I am trying to set up a netlify-cms instance with Hugo, that uses the local netlify-git-api backend: https://github.com/netlify/netlify-git-api

But I am unable to get it to work.

I have successfully installed netlify-git-api on my path in Ubuntu 16.04 and set up users with netlify-git-api users add

When I run netlify-git-api serve I get Starting server on 127.0.0.1:8080

And when I visit http://localhost:8080/ I see the following:

Local Netlify CMS Backend
This is a simple local backend for Netlify's CMS 

When I run hugo server on my project directory and visit http://localhost:1313/admin/ I get the following

Error loading the CMS configuration
The config.yml file could not be loaded or failed to parse properly.
Error message: Error: Backend not found: netlify-api

I have tried changing netlify-api to netlify_api in config.yml as mentioned in this issue https://github.com/netlify/netlify-cms/issues/40 but nothing happens.

The contents of config.yml under/admin/ in my project directory are the following:

backend:
  name: netlify-api
  url: http://localhost:8080

# Use the Editorial workflow - https://github.com/netlify/netlify-cms/blob/master/docs/editorial_workflow.md
publish_mode: editorial_workflow

# Save image uploads to static/img
media_folder: "static/images"
public_folder: "/images"

# Collections
collections: # A list of collections the CMS should be able to edit
  # Used in routes, ie.: /admin/collections/:slug/edit
  - name: "exhibitions"
    # Used in the UI, ie.: "New Post"
    label: "Exhibition"
    # The path to the folder where the documents are stored
    folder: "content/exhibitions"
    # Allow users to create new documents in this collection
    create: true
    # Filename template e.g. YYYY-MM-DD-title.md
    slug: "{{slug}}"
    # The fields each document in this collection have
    fields:
      - {label: "Title", name: "title", widget: "string", tagname: "h1"}
      # Use required: false instead of optional: true - https://github.com/netlify/netlify-cms/issues/315
      - {label: "Description", name: "description", widget: "text", required: false}
      - {label: "Body", name: "body", widget: "markdown"}
    meta:
      - {label: "Date", name: "date", widget: "datetime"}
# Does not currently work, see https://github.com/netlify/netlify-cms/issues/248
#      - {label: "Tags", name: "tags", widget: "list"}
#      - {label: "Categories", name: "categories", widget: "list"}

And the index.html under/admin/contains:

<!doctype html>
<html>
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Content Manager</title>

  <link rel="stylesheet" href="https://unpkg.com/netlify-cms@^0.3/dist/cms.css" />

</head>
<body>
  <script src="https://unpkg.com/netlify-cms@^0.3/dist/cms.js"></script>
</body>
</html>

What am I doing wrong? Or is the netlify-git-api deprecated?

onedrawingperday commented 7 years ago

I am closing this because I will not be using Netlify CMS, after all.

olliekav commented 7 years ago

I have the same problem with Middleman, same setup as above. No matter what I try I can't get it to pick up the admin locally. Tried netlify_api and netlify-api

The config.yml file could not be loaded or failed to parse properly.
Error message: Error: Backend not found: netlify_api
erquhart commented 7 years ago

@olliekav can you join us on Gitter and explain your use case a bit?

dommmel commented 7 years ago

Has netlify-git-api been removed as a backend?

tortilaman commented 7 years ago

@dommmel the netlify-api backend has not been removed.

dommmel commented 7 years ago

@tortilaman thanks. It seems that I have problems navigating the source code resp. documentation. Just to be make sure: I am talking about supporting a local git repo via "netlify-git" or netlify-git-api.

putting the following in config.yml does yields the above error.

backend:
  name: netlify-api

as far as I can see netlify-git has been removed in a4d7622adead7e259caccdac5c97499d977de070 or has it been refactored into netlify-auth? How would I use it now? Thanks for your help.

tortilaman commented 7 years ago

sorry @dommmel, I thought you were referring to the netlify-auth backend. I previously setup netlify-api with a lot of trial and error, but I couldn't begin to tell you how.

One thing to be aware of is that the way the netlify-git-api handles users and authentication is completely different from other available authentication options. You manually create users, and there isn't any kind of OAuth happening. I would probably recommend using the github auth unless you want this type of authentication for your specific use-case.

Benaiah commented 7 years ago

Yeah, as far as I know the netlify-api backend isn't supported at the moment. We have plans for a local backend, but that work's not completed yet. At the moment, the only working backends that edit real data are the GitHub backend (there's an in-memory test backend, but it doesn't really count) and tbe netlify-auth backend, which I believe is a wrapper for the GitHub backend that just allows for some different workflows, but which I'm not super familiar with. There's also a GitLab backend in the works (https://github.com/netlify/netlify-cms/pull/517).