/disqus-proxy-serverless

实现 Disqus 代理的 Serverless 服务 解决国内不能访问 Disqus 的问题 可用于hexo等博客

Primary LanguageJavaScript

disqus-proxy-serverless

如有疑问请阅读这篇博客, inspired by szhielelp

使用步骤

  1. clone代码 并配置src目录下的config.js

    git clone https://github.com/jacklightChen/disqus-proxy-serverless.git
    cd disqus-proxy-serverless
    
    module.exports = {
      // 因为要部署在Serverless服务上,端口无所谓,随便填
      port: 5050, 
      // Your Disqus Public Key
      api_key: '',
      // Your Disqus Secret Key
      api_secret: '',
      // Your Disqus Name
      username: 'jacklightchen',
    };

    各种 Key 需要在 Disqus 的 API 页面 申请

    重要 另外需要到 Settings => Community 里开启访客评论

  2. 部署至Serverless平台Now

    tips:没有安装now 需首先安装now

    npm i -g now
    

    然后输入以下commands

    cd disqus-proxy-serverless
    now login 输入邮箱并验证
    now --name Disqus-Proxy
    

    此时可在自己的 ZEIT 的 Dashboard 那边: https://zeit.co/dashboard

    看到该服务分配的域名: disqus-proxy.1797079433.now.sh 这个域名需填在hexo的配置文件中

    到这一步服务端就部署好了,可通过: disqus-proxy.1797079433.now.sh/api/listPosts 测试,正确的话会返回json格式的评论

  3. 修改hexo的配置文件

    使用 disqus-proxy

    3.1 在Hexo博客目录执行

    npm install hexo-disqus-proxy --save
    

    3.2 在你的Hexo博客目录中修改_config.yml文件 添加如下配置:(注意缩进和空格)

    配置文件需要注意port 如果用https就是443 http就是80

    disqus_proxy:
      shortname: jacklightchen
      username: jacklightchen
      host: disqus-proxy.1797079433.now.sh
      port: 443
    
  4. 大功告成 重新部署你的hexo查看效果吧!