gethypervisual / gridsome-plugin-netlify-cms

Gridsome.js plugin to include Netlify CMS
Other
15 stars 9 forks source link

[Bug] __PATH_PREFIX__ is not defined #5

Closed andrevandal closed 5 years ago

andrevandal commented 5 years ago

Describe the bug When I log in my Netlify CMS with Netlify Identity, I got the error __PATH_PREFIX__ is not defined and the cms doen'st redirect me to cms's page.

To Reproduce

  1. Only install and try to use

Expected behavior Redirect to /admin/ page

Screenshots image

Applicable Versions:

CMS configuration

backend:
  name: git-gateway
site_url: https://institutoalves.com.br
media_folder: "static/uploads"
public_folder: "/uploads"
show_preview_links: false

collections:
  - name: "talks"
    label: "Palestras"
    folder: "content/talks"
    create: true
    slug: "palestras/{{slug}}"
    fields:
      - {label: "Título", name: "title", widget: "string" }
      - {label: "Link", name: "link", widget: "string", default: "/contato" }
      - {label: "Imagem", name: "image", widget: "image" }
      - {label: "Descrição", name: "description", widget: "string" }
      - {label: "Rascunho", name: "draft", widget: "boolean", default: true}
      - {label: "Conteúdo", name: "body", widget: "markdown" }
    editor:
      preview: false
  - name: "store"
    label: "Produtos"
    folder: "content/store"
    create: true
    slug: "{{type}}/{{slug}}"
    fields:
      - {label: "Título", name: "title", widget: "string"}
      - label: "Preço"
        name: "price"
        widget: "object"
        fields:
          - {label: "De:", name: "from", widget: string }
          - {label: "Por:", name: "to", widget: string }
      - {label: "Link", name: "link", widget: "string"}
      - {label: "Imagem", name: "image", widget: "image"}
      - label: "Tipo"
        name: "type"
        widget: "select"
        options:
          - {label: "Brinquedos Pedagógicos", value: "brinquedos-pedagogicos" }
          - {label: "Livros", value: "livros" }
          - {label: "Outros", value: "outros" }
      - {label: "Rascunho", name: "draft", widget: "boolean", default: true}
      - {label: "Conteúdo", name: "body", widget: "markdown"}
    editor:
      preview: false
  - name: "blog"
    label: "Publicações"
    folder: "content/posts"
    create: true
    slug: "blog/{{slug}}"
    fields:
      - {label: "Título", name: "title", widget: "string"}
      - {label: "Imagem", name: "image", widget: "image"}
      - {label: "Rascunho", name: "draft", widget: "boolean", default: true}
      - {label: "Conteúdo", name: "body", widget: "markdown"}
  - label: "Páginas"
    name: "pages"
    create: false
    files:
      - label: "Página Inicial"
        name: "home"
        file: "content/settings/home.yml"
        fields:
          - {label: "Youtube URL", name: "homeYoutubeURL", widget: "string"}
      - label: "Contato"
        name: "contact"
        file: "content/settings/contact.yml"
        fields:
          - {label: "WhatsApp URL", name: "contactWhatsappUrl", widget: "string"}
      - label: "Sobre Nós"
        name: "about-us"
        file: "content/settings/about-us.yml"
        fields:
          - {label: "Conteúdo", name: "body", widget: "markdown"}
    editor:
      preview: false

Additional context I'm using Gridsome, this is my configs:

// gridsome.config.js
module.exports = {
  plugins: [
    /*  ... */
    {
      use: `gridsome-plugin-netlify-cms`,
      options: {
        htmlTitle: 'Editor'
      }
    }
  ]
}
andrevandal commented 5 years ago

I think can be related with https://github.com/gatsbyjs/gatsby/issues/14898

andrevandal commented 5 years ago

I remove ${__PATH_PREFIX__} from my fork (https://github.com/derevandal/gridsome-plugin-netlify-cms/) and this error disappears.

tobymarsden commented 5 years ago

@derevandal Thanks! I just published v1.0.8; does this work for you?

travis-r6s commented 5 years ago

@tobymarsden I still get this error with v1.0.9? Exactly the same setup as @derevandal ...

tobymarsden commented 5 years ago

@thetre97 Please could you post your Netlify CMS version, Gridsome version, and your Netlify config.yml?

travis-r6s commented 5 years ago
"gridsome": "^0.6.7",
"gridsome-plugin-netlify-cms": "^1.0.9",
"gridsome-plugin-netlify-cms-paths": "^0.3.0",
backend:
  name: git-gateway
  site_url: https://<site>.netlify.com
  accept_roles:
    - admin
    - editor

media_folder: static/assets
public_folder: assets

collections:
  - label: "Pages"
    name: "pages"
    files:
      - file: "content/pages/home/index.md"
        label: "Home"
        name: "home"
        fields:
          - { label: "Template Key", name: "templateKey", widget: "hidden", default: "home-page" }
...
travis-r6s commented 5 years ago

In general it works absolutely fine, I can login etc. It is just the first time after setting a new password (as a newly registered user) that it shows that error.

tobymarsden commented 5 years ago

@thetre97 Ah, gotcha. Maybe that's why I'm struggling to reproduce it on 1.0.9. I'll try to get a test repo set up in the next couple of days. Thanks!

oliverpool commented 4 years ago

I have the same issue.

This is caused by https://github.com/gethypervisual/gridsome-plugin-netlify-cms/blob/master/gridsome.client.js (for which the '__PATH_PREFIX__') does not get injected.

As a workaround, I have added the following to my gridsome.config.js file:

  configureWebpack: {
    plugins: [
      new DefinePlugin({
        __PATH_PREFIX__: JSON.stringify("") // or whatever value you actually need
      })
    ]
  },