0
votes

Gatsby-Source-WordPress Gatsby Develop returns: "The server response was "404 Not Found"

Running Gatsby default Starter Fresh install of wordpress all on localhost.

wordpress is here: localhost/freshinstall I see json data here: localhost/freshinstall/wp-json/ Permalinks in wordpress set to: Post Name

gatsby-source-wordpress is the only plugin installed in gatsby:

   {
      resolve: `gatsby-source-wordpress`,
      options: {
        // your wordpress source
        baseUrl: `localhost/freshinstall`,
        protocol: `http`,
        hostingWPCOM: false,
        useACF: true
      }
    },

Expecting to be able to access information in wordPress.

The following is what I see:

my-default-starter dk$ gatsby develop
success open and validate gatsby-configs - 0.067 s
success load plugins - 42.771 s
success onPreInit - 0.034 s
success initialize cache - 0.061 s
success copy gatsby files - 2.423 s
success onPreBootstrap - 0.052 s

Path: /freshinstall/wp-json
The server response was "404 Not Found"

 ERROR 

Plugin gatsby-source-wordpress returned an error Cannot read property 'data' of undefined



  TypeError: Cannot read property 'data' of undefined

  - fetch.js:134 fetch
    [my-default-starter]/[gatsby-source-wordpress]/fetch.js:134:21

  - next_tick.js:68 process._tickCallback
    internal/process/next_tick.js:68:7


warn The gatsby-source-wordpress plugin has generated no Gatsby nodes. Do you need it?
success source and transform nodes - 1.840 s
success building schema - 1.270 s
success createPages - 0.007 s
success createPagesStatefully - 1.266 s
success onPreExtractQueries - 0.089 s
success update schema - 0.078 s
success extract queries from components - 25.299 s
success write out requires - 0.165 s
success write out redirect data - 0.044 s
success Build manifest and related icons - 0.402 s
success onPostBootstrap - 0.458 s
⠀
info bootstrap finished - 269.881 s
⠀
success Generating image thumbnails — 6/6 - 2.762 s
success run static queries - 3.311 s — 3/3 0.91 queries/second
success run page queries - 0.077 s — 5/5 93.18 queries/second
 DONE  Compiled successfully in 105741ms                                                                                                  3:25:50 PM
⠀
You can now view gatsby-starter-default in the browser.
⠀
  http://localhost:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
  http://localhost:8000/___graphql
⠀
Note that the development build is not optimized.
To create a production build, use npm run build
⠀
ℹ 「wdm」:
ℹ 「wdm」: Compiled successfully.

4

4 Answers

0
votes

Turns out my own machine was messed up.

It took forever to resolve, what ultimately solved the issue was changing how apache was setup on the machine. The link localhost/domain wasn't literally what it was. I broke apache, broke mysql, then fixed both then had to change a port and finally it works like this now:

localhost:8888/domain

Everything in Gatsby-Source-WordPress worked after that.

0
votes

I'm new at Stack Overflow and don't know should I ask new question or can I ask here. Let's try.

I'm following this tutorial. I get the same error as you got. I think I have also same kind of setup as you have, running wordpress locally with Mamp. My WP is running at http://localhost:8888/GatsbyWP/ and I can see JSON data at http://localhost:8888/GatsbyWP/wp-json/ .

I can't solve it and don't know where to start to solve this. Can you tell more specific what you did to Apache and MySQL? If that could be also my proplem. Thanks!

0
votes

I stumbled on this same problem and here are the things I did:

  • My MAMP settings had the default port as 80. Local Wordpress could be accessed through http://localhost. I reverted MAMP ports to default, so the local url became http://localhost:8888/your domain name if applied

  • I forced stop sqld which was running concurrently on my Mac.

  • I went to phpMyAdmin and disabled all the active plugins.

  • I went to wp-admin and reset permalinks to post name. That had already been set as post name, but still click the Save button anyway to commit the change.

Looking back, I have no idea what was the culprit, but hope this helps someone.

0
votes

Hey your config should look like this but if not let me know and i'll fix :).

{
      resolve: `gatsby-source-wordpress`,
      options: {
        baseUrl: process.env.API_URL,

        protocol: process.env.API_PROTOCOL,

        hostingWPCOM: false,

        useACF: true,

        includedRoutes: [
          "**/categories",
          "**/posts",
          "**/pages",
          "**/media",
          "**/tags",
          "**/taxonomies",
          "**/users",
          "**/menus",
          "**/portfolio",
          "**/services",
          "**/qualifications",
          "**/gallery",
          "**/logo",
          "**/location",
        ],
      },
    },
}