而使用盖茨比部署到GitHub的网页内容安全策略

问题描述 投票:0回答:1

所以我一直试图让我的盖茨比网页工作,Github上的页面,但我仍然是一个牛逼的阵营和Javascript。

这是回购协议(https://github.com/alexing/alexing.github.io)。

火狐控制台引发此404错误。

Refused to load the image 'http://www.alexingberg.com/favicon.ico' because it violates the following Content Security Policy directive: "img-src data:".

这是我的package.json

{
  "name": "alexing.github.io",
  "description": "alexingberg.com",
  "repository": {
    "type": "git",
    "url": "https://github.com/alexing/alexing.github.io"
  },
  "homepage": "https://alexing.github.io",
  "license": "MIT",
  "scripts": {
    "develop": "gatsby develop",
    "build": "gatsby build",
    "serve": "gatsby serve",
    "deploy": "gatsby build && gh-pages -b master -d public",
    "deploy:github": "npm run build && node ./scripts/deploy-github"
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.12",
    "flexboxgrid": "^6.3.1",
    "font-awesome": "^4.7.0",
    "gatsby": "^1.9.279",
    "gatsby-link": "^1.6.39",
    "gatsby-plugin-google-analytics": "^1.0.24",
    "gatsby-plugin-google-fonts": "0.0.4",
    "gatsby-plugin-sass": "^1.0.23",
    "gh-pages": "^2.0.1",
    "include-media": "^1.4.9",
    "milligram-scss": "^1.3.0",
    "node-sass": "^4.11.0",
    "react-helmet": "^5.2.0"
  },
  "devDependencies": {
    "@fortawesome/fontawesome-free": "^5.6.3"
  }
}

我已经安装了GH-网页,我试图用www.alexingberg.com作为CNAME。我想我已经浏览所有互联网的问题,但并没有发现对于404我得到一个答案。

让我知道如果你需要更多的数据,我会添加它。谢谢!

javascript reactjs github github-pages gatsby
1个回答
0
投票

您可以创建一个在你的项目的根命名static文件夹。你把该文件夹中的每个文件都将被复制到公用文件夹把你CNAME文件中的static/文件夹,它会被复制不变的根或盖茨比构建的public/文件夹,准备由gh-pages被复制到GitHub的页面

部署脚本将会是这个样子

 "deploy": "gatsby build && cp ./static/CNAME public/ &&gh-pages -d public --branch master"

此外,你应该做一个单独的分支如“发展”,然后切换跳转到主部署。

© www.soinside.com 2019 - 2024. All rights reserved.