我正在尝试使用Wordpress和Gatsby创建一个静态网站,在本地一切正常,但是当我尝试在一个临时网站上使用它时,我得到了这个错误:
Path: /wp-json
The server response was "401 Unauthorized"
Inner exception message: "You are not currently logged in."
ERROR #11321 PLUGIN那么有没有办法让Gatsby使用我的凭证访问我的Wordpress网站呢?
我的gatsby-config.js:
module.exports = {
siteMetadata: {
},
plugins: [
{
resolve: `gatsby-source-wordpress`,
options: {
baseUrl: `web-staging.******.io`,
protocol: `https`,
hostingWPCOM: false,
useACF: false,
},
},
`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.
},
},
],
}发布于 2020-05-20 00:42:57
请参阅插件的options,特别是auth
auth: {
// If auth.user and auth.pass are filled, then the source plugin will be allowed
// to access endpoints that are protected with .htaccess.
htaccess_user: "your-htaccess-username",
htaccess_pass: "your-htaccess-password",https://stackoverflow.com/questions/61896161
复制相似问题