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

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

Closed
cjkoepke opened this issue Jan 29, 2018 · 4 comments
Closed

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

cjkoepke opened this issue Jan 29, 2018 · 4 comments

Comments

@cjkoepke
Copy link

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

...

@KyleAMathews
Copy link
Contributor

The plugin auto-discovers additional routes to visit — I'm guessing there's some sort of global wordpress baseUrl setting you need to change on your local instance of WP

route: { url: menu.meta.links.self, type: `${type}_items` },

@cjkoepke
Copy link
Author

@KyleAMathews I've done a search/replace across the whole WP database and don't see any more calvinkoepke.com references. Do you think it'd be in a theme/plugin file or something?

@KyleAMathews
Copy link
Contributor

This is past my WP working knowledge at this point :-)

I'd look at what the REST API is putting out and go from there.

@cjkoepke
Copy link
Author

@KyleAMathews It must've been some crazy caching because now it's pulling the right URL. I also removed .cache before to try and it didn't update.

Either way, it's no longer an issue.

This was referenced Sep 5, 2021
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

2 participants