首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Gatsby登录Wordpress

使用Gatsby登录Wordpress
EN

Stack Overflow用户
提问于 2020-05-20 00:33:27
回答 1查看 470关注 0票数 1

我正在尝试使用Wordpress和Gatsby创建一个静态网站,在本地一切正常,但是当我尝试在一个临时网站上使用它时,我得到了这个错误:

代码语言:javascript
复制
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:

代码语言:javascript
复制
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.
      },
    },
  ],
}
EN

回答 1

Stack Overflow用户

发布于 2020-05-20 00:42:57

请参阅插件的options,特别是auth

代码语言:javascript
复制
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",
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61896161

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档