Skip to content

[gatsby-source-wordpress] baseUrl differs from actual fetch #3767

@cjkoepke

Description

@cjkoepke

Description

I'm currently trying to import WordPress via gatsby-source-wordpress, but running into an issue where it's fetching from a URL different than the baseUrl option. I honestly don't even know where it's getting the domain from.

Environment

Gatsby version: v1.1.23
Node.js version: v9.2.0
Operating System: MacOS 10.13.2

File contents (if changed):

gatsby-config.js:

const cssnano = require('cssnano')

module.exports = {
	siteMetadata: {
		title: 'Web Engineer + Entrepreneur.',
		desc: `Hey, I'm Calvin. I build web software. I build products, occasionally blog, and offer consulting services under my LLC, Freeshifter.`
	},
	plugins: [
		`gatsby-plugin-react-helmet`,
		`gatsby-plugin-react-next`,
		{
			resolve: `gatsby-plugin-postcss-sass`,
			options: {
				postCssPlugins: [cssnano()],
				precision: 8
			}
		},
		{
			resolve: `gatsby-plugin-google-analytics`,
			options: {
				trackingId: "####"
			},
		},
		{
			resolve: `gatsby-source-wordpress`,
			options: {
				baseUrl: "blog.dev",
				protocol: "http",
				auth: false,
				hostingWPCOM: false,
				useACF: false,
				verboseOutput: true,
			},
		}
	]
}

package.json:

{
	"name": "gatsby-starter-default",
	"description": "Gatsby default starter",
	"version": "1.0.0",
	"author": "Kyle Mathews <[email protected]>",
	"dependencies": {
		"axios": "^0.17.1",
		"fs-extra": "^5.0.0",
		"gatsby": "^1.9.119",
		"gatsby-link": "^1.6.28",
		"gatsby-plugin-google-analytics": "^1.0.15",
		"gatsby-plugin-postcss-sass": "^1.0.15",
		"gatsby-plugin-react-helmet": "^1.0.8",
		"gatsby-plugin-react-next": "^1.0.7",
		"gatsby-plugin-styled-components": "^2.0.4",
		"gatsby-remark-prismjs": "^1.2.12",
		"gatsby-source-contentful": "^1.3.31",
		"gatsby-source-wordpress": "^2.0.51",
		"gatsby-transformer-remark": "^1.7.28",
		"jsonp": "^0.2.1",
		"normalize.css": "^7.0.0",
		"url-search-params": "^0.10.0",
		"validator": "^9.2.0"
	},
	"keywords": [
		"gatsby"
	],
	"license": "MIT",
	"main": "n/a",
	"scripts": {
		"build": "gatsby build",
		"develop": "gatsby develop",
		"format": "prettier --trailing-comma es5 --no-semi --single-quote --write \"src/**/*.js\"",
		"test": "echo \"Error: no test specified\" && exit 1",
		"deploy": "gatsby build --prefix-paths && gh-pages -d public"
	},
	"devDependencies": {
		"cssnano": "^3.10.0",
		"dotenv": "^4.0.0",
		"gatsby-plugin-sass": "^1.0.15",
		"gh-pages": "^1.1.0",
		"prettier": "^1.8.2"
	}
}

gatsby-node.js: not changed
gatsby-browser.js: not changed
gatsby-ssr.js: not changed

Actual result

After running gatsby develop, terminal starts checking for endpoints and displays correct variables:

=START PLUGIN=====================================

Site URL: http://blog.dev
Site hosted on Wordpress.com: false
Using ACF: false
Using Auth: undefined undefined
Verbose output: true

Mama Route URL: http://blog.dev/wp-json

⠐ source and transform nodesRoute discovered : /
Invalid route.
Route discovered : /oembed/1.0
Invalid route.
Route discovered : /oembed/1.0/embed
Invalid route.
Route discovered : /oembed/1.0/proxy
Invalid route.
Route discovered : /akismet/v1
Valid route found. Will try to fetch.
Route discovered : /akismet/v1/key
Valid route found. Will try to fetch.

...

But later down when it actually tries to fetch endpoints:

Fetching the JSON data from 23 valid API Routes...

=== [ Fetching wordpress__akismet_v1 ] === https://calvinkoepke.com/wp-json/akismet/v1

...

All of these return a 404 because there is no WP installation at calvinkoepke.com, but I haven't defined that anywhere (to my knowledge).

Expected behavior

It should be fetching the baseUrl, as defined in the config: http://blog.dev/[endpoint]

Steps to reproduce

1. Install the plugin.

2. Set the baseUrl to a local WP url.

3. Run gatsby develop

...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions