Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: BaseUrl config parameter is invalid or there is no internet connection #41

Open
koloyyee opened this issue Sep 5, 2019 · 2 comments

Comments

@koloyyee
Copy link

koloyyee commented Sep 5, 2019

Hi guys,
I am really new to Web development, recently I came across with Gatsby and wanted to use cockpit as the CMS for the backend.

After some googling, I found this plugin.
I was a little bit confuse with folder structure however I read the tutorial on Medium, so I have the gatsby folder and cockpit folder separated.

I have start the PHP server with

php -S localhost:8080

And I logged into admin page everything works pretty well.

for the gatsby-config.js

{
      resolve: 'gatsby-source-filesystem',
      options: {
        name: 'src',
        path: `${__dirname}/src/`,
      },
    },
    {
      resolve: '@fika/gatsby-source-cockpit',
      options: {
        token: 'b9723f07b8d190db7cb6996837d48b',
        baseUrl:'http://localhost:8080', // (1)
        locales: ['en'], // (2)
        collections: ['pages', 'projects'], // (3)
        singletons: [], // (4)
        aliases: {
          collection: {
            pages:"pages",
            projects:"projects"
          },
          singleton: {
           
          }
        }, // (5)
      },
    },

but I got an error when i do gatsby develop

"@fika/gatsby-source-cockpit" threw an error while running the sourceNodes lifecycle:

BaseUrl config parameter is invalid or there is no internet connection



  Error: BaseUrl config parameter is invalid or there is no internet connection
  
  - CockpitService.js:44 CockpitService.validateBaseUrl
    [website]/[@fika]/gatsby-source-cockpit/src/CockpitService.js:44:13
  

warn The @fika/gatsby-source-cockpit plugin has generated no Gatsby nodes. Do you need it?

I hope to find out what's the problem and solution, it is quite an important project for me, hopefully I would get some love from you guys! Thank you very much!

@DigitalGoldfish
Copy link
Collaborator

I see nothing obviously wrong with your configuration. I would recommend adding some console.log statements in CockpitService.validateBaseUrl and log out the error. Maybe we are hiding something relevant there ...

@benedictjohannes
Copy link

Looks like Cockpit does not support GET request on /api route.

Running the latest version of Cockpit (master branch v0.10.0 on commit 23e3a49e ) on localhost:8080, requestingGET localhost:8080/api?token=COCKPIT_TOKEN will redirect to the Cockpit index page.
When I replaced the validateBaseUrl with this:

async validateBaseUrl() {
    try {
      await this.fetch('/collections/listCollections', METHODS.GET)
    } catch (error) {
      throw new Error(
        'BaseUrl config parameter is invalid or there is no internet connection'
      )
    }
  }

It works. Since both validateBaseUrl() does not work, I think the simplest solution is eliminating this function altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants