我正在使用cloudfront分发位于S3 存储桶中的静态网站对象。我正在使用Route53来处理我的 DNS 路由和健康检查。
我最近遇到了在不同功能分支之间进行拆分测试的Netlify 。我想坚持使用我当前在 AWS 上的堆栈,但想为 AB 测试构建此功能。
最初,我想让 Route53 为 2 个独立的 Cloudfront 服务提供服务,每个服务都有自己的 S3 存储桶。我会使用加权循环将 10% 的流量分配给测试环境,将另外 90% 的流量分配给生产环境。我很快了解到 Amazon 不允许同一个域为 2 个不同的 Cloudfront 服务提供服务,每个服务都服务于自己的 S3。
在另一种选择是在我的CloudFront的服务的边缘节点都做这个测试。这将要求我从同一个 S3 提供两个不同的对象,这看起来非常混乱且不可扩展。
在使用 AWS 时,甚至可以复制 Netlify 对 Split 测试所做的事情吗?如果是这样,我该如何实施?如果没有,AB 测试静态网站的下一个最佳选择是什么?
amazon-s3 amazon-web-services amazon-cloudfront amazon-route53 netlify
我在 server.js 中有这个
//socket io config
const server = require('http').createServer(app)
const io = require('socket.io')(server)
io.on('connection', function (socket) {
socket.on('SOCKET_COMMENT_RECEIVED', ({ notification }) => {
io.emit(`SOCKET_COMMENT_RECEIVED`, notification)
})
//and many more
})
Run Code Online (Sandbox Code Playgroud)
在我的客户端(反应)
import io from 'socket.io-client'
const socket = io('localhost:3001') // working in localhost
Run Code Online (Sandbox Code Playgroud)
在我的产品中我做了这个检查
let socket = io('localhost:3001')
if(process.env.NODE_ENV === 'production') { socket =
io('https://api.example.com:3001')
}
Run Code Online (Sandbox Code Playgroud)
为什么会这样呢?我不认为这是 cors 问题,因为我已经这样做了
app.use(cors({
origin: true,
credentials: true
}))
Run Code Online (Sandbox Code Playgroud)
我的 package.json 依赖项
"socket.io": "^2.1.1",
"socket.io-client": "^2.1.1",
Run Code Online (Sandbox Code Playgroud) 我在 Netlify 上托管了两个网站。第一个具有以下域
mydomain.io
www.mydomain.io
Run Code Online (Sandbox Code Playgroud)
Netlify 的一键 HTTPS 完美运行。在 AWS Route 53 中,我有以下配置:
NS mydomain.io
dns3.p08.nsone.net
dns1.p08.nsone.net
dns2.p08.nsone.net
dns4.p08.nsone.net
Run Code Online (Sandbox Code Playgroud)
和
CNAME www.mydomain.io
random-words-d12345.netlify.com
Run Code Online (Sandbox Code Playgroud)
我的第二个网站有问题。Netlify中的域如下:
app.mydomain.io
Run Code Online (Sandbox Code Playgroud)
在 53 号公路中:
CNAME app.mydomain.io
Run Code Online (Sandbox Code Playgroud)
我无法在 Netlify 中启用 HTTPS。我也尝试过使用NS app.mydomain.io相同的名称服务器,但也没有运气。
我的 nuxt 应用程序在本地运行没有问题,但是当我尝试将站点部署到 Netlify 时,出现如下错误:
“未找到模块:错误:无法解析‘/opt/build/repo/layouts’中的‘~/components/Navbar.vue’”
我收到以下错误:
ERROR in ./layouts/default.vue?vue&type=script&lang=js& (./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib??vue-loader-options!./layouts/default.vue?vue&type=script&lang=js&)
6:49:50 PM: Module not found: Error: Can't resolve '~/components/Navbar.vue' in '/opt/build/repo/layouts'
6:49:50 PM: @ ./layouts/default.vue?vue&type=script&lang=js& (./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib??vue-loader-options!./layouts/default.vue?vue&type=script&lang=js&) 8:0-45 11:12-18
6:49:50 PM: @ ./layouts/default.vue?vue&type=script&lang=js&
6:49:50 PM: @ ./layouts/default.vue
6:49:50 PM: @ ./.nuxt/App.js
6:49:50 PM: @ ./.nuxt/index.js
6:49:50 PM: @ ./.nuxt/client.js
6:49:50 PM: @ multi ./.nuxt/client.js
Run Code Online (Sandbox Code Playgroud)
请帮忙,提前致谢。
我在 Namecheap购买了域名my-domain.com。我的目标是将my-domain.com 的子域与 Digital Ocean 和my-domain.com与 Netlify 一起使用。想要的结果:
我对所有 DNS 设置都非常不清楚,感谢您的帮助!
谢谢你。
我正在使用 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 变量未应用于最新版本。
我可以通过在搜索栏中输入 url 来更改托管在 netlify(手动部署)上的 flutter web的 url ,从而导航到其他页面,如下所示:-

因此,如果我将 /home 更改为 /about 那么它会完美地引导我到 about 页面。但是为了从我的网址中删除这个“#”,我在我的 main.dart我的代码中添加了以下代码 :-
import 'package:url_strategy/url_strategy.dart';
void main()async {
await Firebase.initializeApp();
setPathUrlStrategy();//this removes the '#' from my url
FluroRouting.setupRouter();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'My Website',
theme: ThemeData(
primarySwatch: Colors.blue,
),
initialRoute: '/home',
onGenerateRoute: FluroRouting.router.generator,
);
}
}
Run Code Online (Sandbox Code Playgroud)
路由代码是:-
class FluroRouting {
static final router = FluroRouter();
static Handler _aboutUsHandler = …Run Code Online (Sandbox Code Playgroud) 我尝试将我的 Gatsby 站点部署到 Netlify,但每当我尝试部署时,我总是收到各种节点模块的这些错误。我尝试制作一个 webpack.config.js 文件并包含两个建议的解决方案,但均无济于事。我还尝试使用别名而不是后备,将浏览器部分添加到 package.json 文件中,将模块设置为 false,并按照其他一些 stackoverflow 答案的建议在 webpack.config.js 文件中添加目标属性,但是我还是很困惑。我之前没有任何 webpack 经验,并且一直在尽力寻找答案。我缺少 Gatsby 的某种特殊配置吗?
错误信息
10:37:20 AM: error Generating JavaScript bundles failed
10:37:20 AM: Can't resolve 'stream' in '/opt/build/repo/node_modules/cipher-base'
10:37:20 AM: If you're trying to use a package make sure that 'stream' is installed. If you're trying to use a local file make sure that the path is correct.
10:37:20 AM: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
10:37:20 …Run Code Online (Sandbox Code Playgroud) 我过去已经这样做过很多次了,我在 netlify 日志中收到此错误。我尝试部署的存储库是https://github.com/yanyamz/Key_Visual_Arts。
\n我检查了它是否在 Netlify 的大小限制内,结果是,总共 15mb 左右,而您可以在 netlify 上部署的 20+mb 左右。
\n12:03:03 PM: Build ready to start\n12:03:04 PM: build-image version: fa439ad1ab9393b2c0d449d8d7c033927683f4b0\n12:03:04 PM: build-image tag: v4.3.0\n12:03:04 PM: buildbot version: 0f2f658d862cfe72bae7cc05c6a8de0426a5a0e2\n12:03:04 PM: Fetching cached dependencies\n12:03:05 PM: Failed to fetch cache, continuing with build\n12:03:05 PM: Starting to prepare the repo for build\n12:03:05 PM: No cached dependencies found. Cloning fresh repo\n12:03:05 PM: git clone https://github.com/yanyamz/Key_Visual_Arts\n12:03:07 PM: Preparing Git Reference refs/heads/main\n12:03:07 PM: Parsing package.json dependencies\n12:03:08 PM: \n\xe2\x80\x8b\n\xe2\x9d\xaf Initial build environment\nbaseRelDir: …Run Code Online (Sandbox Code Playgroud) 在我的索引页中,我正在使用serverSideTranslations函数。查找翻译文件时出现错误。此错误仅发生在使用 的页面上serverSideTranslations。
我部署到 Vercel 和 Netlify。在他们两个中我都遇到了同样的错误。
在_app.js我正在使用appWithTranslation.
依赖项:
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.4",
"@netlify/plugin-nextjs": "^3.9.2",
"axios": "^0.21.1",
"bootstrap": "^4.6.0",
"dayjs": "^1.10.4",
"dotenv": "^8.2.0",
"fs-extra": "^10.0.0",
"is-mobile": "^3.0.0",
"next": "^11.1.2",
"next-i18next": "^8.9.0",
"next-seo": "^4.20.0",
"node-fetch": "^2.6.1",
"parse": "^3.1.0",
"react": "17.0.1",
"react-bootstrap": "^1.5.0",
"react-dom": "17.0.1",
"react-infinite-scroller": "^1.2.4",
"recoil": "^0.1.2",
"sass": "^1.43.2",
"ts-node": "^9.1.1"
}
Run Code Online (Sandbox Code Playgroud)
next.config.js
const path = require('path');
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants')
const i18NextConfig = require('./next-i18next.config');
const prodConfig = {
generateBuildId: () …Run Code Online (Sandbox Code Playgroud)