问题描述
我正在测试Gatsby和WP如何协同工作,并检查了来自官方插件文档(Wordpress example on Github)的示例
我正在使用 MAMP 在本地进行托管,端口设置为 80&3306 。
我知道错误出在 baseUrl 上的gatsby-config.js中,因为我试图将其更改为虚拟网站(实时),并且问题已解决。因此,我想尝试从本地主机获取WP数据时出了点问题。这是我的gasby-config.js文件:
module.exports = {
siteMetadata: {
title: `Gatsby Default Starter`,description: `Kick off your next,great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,author: `@gatsbyjs`,},plugins: [
`gatsby-plugin-react-helmet`,{
resolve: `gatsby-source-filesystem`,options: {
name: `images`,path: `${__dirname}/src/images`,`gatsby-transformer-sharp`,`gatsby-plugin-sharp`,{
resolve: `gatsby-plugin-manifest`,options: {
name: `gatsby-starter-default`,short_name: `starter`,start_url: `/`,background_color: `#663399`,theme_color: `#663399`,display: `minimal-ui`,icon: `src/images/gatsby-icon.png`,// This path is relative to the root of the site.
},{
resolve: `gatsby-source-wordpress`,options: {
/*
* The base URL of the wordpress site without the trailingslash and the protocol. This is required.
* Example : 'dev-gatbsyjswp.pantheonsite.io' or 'www.example-site.com'
*/
baseUrl: `localhost`,protocol: `https`,hostingWPCOM: false,useACF: false,searchAndReplaceContentUrls: {
sourceUrl: "http://localhost",replacementUrl: "https://localhost:8000",// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more,visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,],}
这是我在终端中遇到的错误:
我尝试过的事情:
- 将MAMP上的端口更改为默认端口(Apache:8888,Nginx:7888,MysqL:8889),但是我根本无法打开m WP站点(在搜索栏中输入localhost:8888时出现服务器错误)
- 将baseUrl更改为虚拟实时网站:问题已解决,但我需要它在localhost上工作
- 将协议更改为http(而不是https),因为我在Stack上读取了类似的线程,但仍然收到相同的错误
- 使用Flywheel将我的WP站点迁移到临时域,并改用该baseUrl(已变为testSite123.flywheelsites.com),但同样,同样的错误。
我觉得选择不对,欢迎任何想法!
解决方法
您可以进行一些试验:
- 将您的MAMP端口恢复或撤消为默认端口,以便
baseUrl
变为:http://localhost:8888
(注意端口)。 - 禁用PhpMyAdmin插件
- 停止SQL服务以避免潜在的并发冲突