我想建立一个 Hugo 网站,可以:
我知道 Bitbucket 允许免费的私人存储库,但我不明白如何使用密码保护某些页面。我目前设置了一个 Github 页面,但存储库是公开的。我知道我可以在 Github 上购买私人仓库,但仍然不明白如何对静态站点页面进行密码保护。
我听说 Netlify 提供了密码保护功能,但需要我每月支付 99 美元。
我考虑过 Wordpress,但如果可能的话,我真的很想使用 SSG。我是一个初学者,但正在练习 CLI 并且取得了一些成功。
请告诉我您的建议。谢谢!
如何在带有Create-React-App的Netlify中使用构建环境变量?
我已经使用 Netlify 和 git 存储库进行了持续部署设置,但到目前为止,无论我做什么,Netlify 都没有npm-install执行任何操作。当我下载部署的 zip 时,没有node_modules 文件夹,我的站点无法访问node_modules,它不在那里。我已经开始使用随机的 npm 包(lodash)来尝试安装它,但到目前为止我什么也没得到。
Netlify 说它会自动运行npm install。我尝试过不使用构建命令,也尝试添加npm install为构建命令,但都没有结果。
包.json:
{
"name": "netlify-test",
"version": "1.0.0",
"description": "stuff",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/electrovir/netlify-test.git"
},
"author": "electrovir",
"license": "MIT",
"bugs": {
"url": "https://github.com/electrovir/netlify-test/issues"
},
"homepage": "https://github.com/electrovir/netlify-test#readme",
"dependencies": {
"lodash": "^4.17.11"
}
}
Run Code Online (Sandbox Code Playgroud)
HTML:
{
"name": "netlify-test",
"version": "1.0.0",
"description": "stuff",
"main": "index.js",
"scripts": {
"test": …Run Code Online (Sandbox Code Playgroud) 我有一个内置使用create-react-app并托管在中netlify。
在此链接中,提到我需要为SPA编写重定向规则。
/* /index.html 200
Run Code Online (Sandbox Code Playgroud)
但是重定向到index.html是行不通的,因为没有使用该URL呈现任何视图。我也尝试过重定向到/喜欢
[[redirects]]
from = "/*"
to = "/"
Run Code Online (Sandbox Code Playgroud)
但这也不起作用。
我该如何进行全面重定向create-react-app?
我正在尝试将 Gatsby starter 与 Netlify CMS 一起使用。https://github.com/stackrole-dev/gatsby-starter-foundation
\n\n我完全按照说明进行操作,但在启用 Git Gateway 后,当我尝试以管理员身份登录时,我遇到了此错误消息。
\n\nYour Git Gateway backend is not returning valid settings. Please make sure it is enabled.\nRun Code Online (Sandbox Code Playgroud)\n\n我不知道为什么它不起作用。
\n\n我的config.yml是
backend:\n name: git-gateway\n commit_messages:\n create: \'Create {{collection}} \xe2\x80\x9c{{slug}}\xe2\x80\x9d\'\n update: \'Update {{collection}} \xe2\x80\x9c{{slug}}\xe2\x80\x9d\'\n delete: \'Delete {{collection}} \xe2\x80\x9c{{slug}}\xe2\x80\x9d\'\n uploadMedia: \'[skip ci] Upload \xe2\x80\x9c{{path}}\xe2\x80\x9d\'\n deleteMedia: \'[skip ci] Delete \xe2\x80\x9c{{path}}\xe2\x80\x9d\'\n\nlocal_backend: true # run npx netlify-cms-proxy-server for local testing\n\nmedia_folder: "static/assets" \npublic_folder: "/assets" \n\ncollections:\nRun Code Online (Sandbox Code Playgroud)\n 上下文: 我正在尝试通过 Netlify 使用 Apollo Server Lambda 部署 GraphQL。我的处理程序如下:
代码:
exports.handler = server.createHandler({
cors: {
origin: '*'
}
});
Run Code Online (Sandbox Code Playgroud)
我能够在 Netlify 上成功构建和部署 - 但是服务器在启动时抛出错误。Netlify 正在寻找要触发的事件,但我使用的 Apollo Server 处理程序没有提供。我们如何将此处理程序连接到使用事件的处理程序?
错误信息:
{"errorType":"Error","errorMessage":"Unable to determine event source based on event.","trace":["Error: Unable to determine event source based on event."," at getEventSourceNameBasedOnEvent (/var/task/node_modules/@vendia/serverless-express/src/event-sources/utils.js:88:9)"," at proxy (/var/task/node_modules/@vendia/serverless-express/src/configure.js:38:51)"," at handler (/var/task/node_modules/@vendia/serverless-express/src/configure.js:99:12)"," at Runtime.handler (/var/task/node_modules/apollo-server-lambda/dist/ApolloServer.js:51:27)"]}
Run Code Online (Sandbox Code Playgroud) 错误与代码库有关(我正在使用的代码库monorepo位于vercel.json根目录中)。在vercel.js与react应用程序一起打包后,一切工作正常。
我有一个简单的React.js应用程序,带有wouter基于 - 的路由和Vercel部署,这让我遇到了一个小问题,我不知道解决方案。404它总是在刷新(子页面)后返回。
我的代码看起来有点像这样。
<>
<Route path='/' component={Intro} />
<Route path='/dashboard' component={Dashboard} />
</>
Run Code Online (Sandbox Code Playgroud)
<Intro />我<Link />必须/dashboard将我转到哪个<Dashboard />页面。它确实可以在我的本地计算机、容器中以及基于 Linux 的部署中运行,但在vercel部署中却无法真正运行,即使我尝试通过vercel.json.
<>
<Route path='/' component={Intro} />
<Route path='/dashboard' component={Dashboard} />
</>
Run Code Online (Sandbox Code Playgroud)
还尝试了替代版本rewrites,但仍然存在相同的问题。
{
"github": {
"silent": true
},
"rewrites": [
{
"source": "(.*)",
"destination": "/index.html"
}
]
}
Run Code Online (Sandbox Code Playgroud)
此处提供的实时部署链接:pointrest-6ttd9zep8-araclx.vercel.app …
我正在使用 vite 制作一个项目,该项目使用 vue-router@4。它工作得很好,但是当查看 vercel 或 netlify 上的链接时,我收到 404 错误。这是我的 index.js 文件(路由器设置)
import { createRouter, createWebHistory } from "vue-router";
import Home from "../views/Home.vue";
import Admin from "../views/Admin.vue";
import List from "../views/List.vue";
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: "/",
component: Home,
},
{
path: "/adminpanel",
component: Admin,
},
{
path: "/list",
component: List
}
],
});
export default router;
Run Code Online (Sandbox Code Playgroud)
我做错了什么吗?感谢您的帮助。
我正在使用 create-react-app,我的代码如下所示
const firebaseConfig = {
apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
authDomain: process.env.REACT_APP_AUTH_DOMAIN,
databaseURL: process.env.REACT_APP_DATABASE_URL,
projectId: process.env.REACT_APP_PROJECT_ID,
storageBucket: process.env.REACT_APP_STORAGE_BUCKET,
messagingSenderId: process.env.REACT_APP_MESSAGING_SENDER_ID,
appId: process.env.REACT_APP_APP_ID
};
Run Code Online (Sandbox Code Playgroud)
.env 文件变量在开发中是可访问的。但是在 netlify 中部署站点时出现错误。
我收到这样的错误
Uncaught FirebaseError: projectId must be a string in FirebaseApp.options
at new t (https://movie-base.netlify.com/static/js/2.84dcc854.chunk.js:1:412130)
at Function.e.databaseIdFromApp (https://movie-base.netlify.com/static/js/2.84dcc854.chunk.js:1:692685)
at new e (https://movie-base.netlify.com/static/js/2.84dcc854.chunk.js:1:688595)
at Object.firestore (https://movie-base.netlify.com/static/js/2.84dcc854.chunk.js:1:720410)
at e._getService (https://movie-base.netlify.com/static/js/2.84dcc854.chunk.js:1:2448)
at e.<computed> [as firestore] (https://movie-base.netlify.com/static/js/2.84dcc854.chunk.js:1:4280)
at Object.p [as firestore] (https://movie-base.netlify.com/static/js/2.84dcc854.chunk.js:1:3996)
at Module.435 (https://movie-base.netlify.com/static/js/main.dfb179dd.chunk.js:1:41914)
at f (https://movie-base.netlify.com/movie/263115:1:994)
at Object.222 (https://movie-base.netlify.com/static/js/main.dfb179dd.chunk.js:1:110)
Run Code Online (Sandbox Code Playgroud)
已解决的问题:错误是我的,自动发布在 netlify 中关闭,因此 netlify.toml 变量未应用于最新版本。
我正在使用 Netlify 来提供一些静态.json文件。它们在浏览器中加载良好,但是当我尝试通过 javascript 获取它们时,我在控制台中收到以下错误:
从源“http://localhost:3000”获取(重定向自)的访问已被 CORS 策略阻止:请求的资源上不存在“Access-Control-Allow-Origin”标头。如果不透明响应满足您的需求,请将请求的模式设置为“no-cors”以在禁用 CORS 的情况下获取资源。
我在 Netlify 仪表板中检查了我网站设置中的所有选项,但没有看到任何启用 CORS 的选项,怎么做?
netlify ×10
reactjs ×4
vercel ×2
vite ×2
bitbucket ×1
cors ×1
deployment ×1
gatsby ×1
github ×1
graphql ×1
hugo ×1
netlify-cms ×1
npm-install ×1
server ×1
serverless ×1
turborepo ×1
vue-router ×1
vue.js ×1