game-deploy
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGame Deployment
游戏部署
Deploy your browser game for public access. here.now is the default — instant static hosting with zero configuration. GitHub Pages is available as an alternative when you need git-based deploys.
将你的浏览器游戏部署以供公开访问。here.now是默认选项——无需配置的即时静态托管服务。当你需要基于Git的部署方式时,可选择GitHub Pages作为替代方案。
here.now Deployment (Default)
here.now部署(默认)
Prerequisites
前提条件
- The skill installed (
here-now)npx skills add heredotnow/skill --skill here-now -g - Optional: or
$HERENOW_API_KEYfor permanent hosting~/.herenow/credentials
- 已安装技能(执行
here-now)npx skills add heredotnow/skill --skill here-now -g - 可选:或
$HERENOW_API_KEY,用于永久托管~/.herenow/credentials
Quick Deploy
快速部署
bash
npm run build
~/.agents/skills/here-now/scripts/publish.sh dist/The script outputs a live URL like .
https://<slug>.here.now/bash
npm run build
~/.agents/skills/here-now/scripts/publish.sh dist/脚本会输出一个实时URL,格式类似。
https://<slug>.here.now/Why here.now is the default
为什么here.now是默认选项
- Zero config — no path, no git repo, no GitHub CLI required
base - Instant — site is live immediately (no waiting for propagation)
- No base path issues — content served from subdomain root (or default)
base: '/' - Works everywhere — only needs ,
curl, andfilejq
- 零配置——无需设置路径、Git仓库,也不需要GitHub CLI
base - 即时生效——站点立即上线(无需等待传播)
- 无基础路径问题——内容从子域名根目录提供(或默认配置)
base: '/' - 兼容性强——仅需依赖、
curl和filejq
Vite base path
Vite基础路径
here.now serves from the subdomain root, so use the default base path:
js
export default defineConfig({
base: '/',
// ... rest of config
});here.now从子域名根目录提供内容,因此请使用默认基础路径:
js
export default defineConfig({
base: '/',
// ... 其余配置
});IMPORTANT: Claim your site within 24 hours
重要提示:请在24小时内认领你的站点
Without an API key, publishes are anonymous and expire in 24 hours. The publish script returns a claim URL — the user MUST visit this URL and create a free here.now account to keep the site permanently. The claim token is only shown once and cannot be recovered. If they don't claim it, the site disappears.
You MUST always tell the user about the 24-hour window and the claim URL after every anonymous publish. This is not optional.
| Feature | Anonymous | Authenticated |
|---|---|---|
| Expiry | 24 hours (then deleted!) | Permanent |
| Max file size | 250 MB | 5 GB |
| Rate limit | 5/hour/IP | 60/hour/account |
To set up an API key for permanent hosting (skip the 24h window entirely):
First check if the key already exists:
If found, export it with and skip the prompt.
test -f .env && grep -q '^HERENOW_API_KEY=.' .env && echo "found"set -a; . .env; set +aOtherwise:
- Ask the user for their email
- Send a magic link:
curl -sS https://here.now/api/auth/login -H "content-type: application/json" -d '{"email": "user@example.com"}' - User clicks the link, copies their API key from the dashboard
- User pastes the key like: (saved to .env and redacted automatically)
HERENOW_API_KEY=their-key-here - Also save to credentials file:
mkdir -p ~/.herenow && grep '^HERENOW_API_KEY=' .env | cut -d= -f2- > ~/.herenow/credentials && chmod 600 ~/.herenow/credentials
若无API密钥,发布的内容为匿名状态,24小时后过期。发布脚本会返回一个认领URL——用户必须访问该URL并创建免费的here.now账户,才能永久保留站点。认领令牌仅显示一次,无法找回。如果用户未认领,站点将被删除。
每次匿名发布后,你必须告知用户24小时的期限和认领URL。这是强制要求。
| 特性 | 匿名部署 | 认证部署 |
|---|---|---|
| 有效期 | 24小时(到期后删除!) | 永久有效 |
| 最大文件大小 | 250 MB | 5 GB |
| 速率限制 | 5次/小时/IP | 60次/小时/账户 |
若要设置API密钥以实现永久托管(完全跳过24小时期限):
首先检查密钥是否已存在:
如果已找到,执行导出密钥,跳过后续提示。
test -f .env && grep -q '^HERENOW_API_KEY=.' .env && echo "found"set -a; . .env; set +a否则:
- 向用户索要邮箱地址
- 发送魔法链接:
curl -sS https://here.now/api/auth/login -H "content-type: application/json" -d '{"email": "user@example.com"}' - 用户点击链接,从控制台复制API密钥
- 用户粘贴密钥,格式如下:(会自动保存到.env文件并脱敏)
HERENOW_API_KEY=their-key-here - 同时保存到凭据文件:
mkdir -p ~/.herenow && grep '^HERENOW_API_KEY=' .env | cut -d= -f2- > ~/.herenow/credentials && chmod 600 ~/.herenow/credentials
Updating a deploy
更新部署内容
bash
npm run build
~/.agents/skills/here-now/scripts/publish.sh dist/ --slug <slug>The slug is saved in after each publish — the script auto-loads it for updates.
.herenow/state.jsonbash
npm run build
~/.agents/skills/here-now/scripts/publish.sh dist/ --slug <slug>每次发布后,slug会保存到中——脚本会自动加载该slug以进行更新。
.herenow/state.jsonDeploy script
部署脚本
Add to :
package.jsonjson
{
"scripts": {
"deploy": "npm run build && ~/.agents/skills/here-now/scripts/publish.sh dist/"
}
}For updates to an existing slug:
json
{
"scripts": {
"deploy": "npm run build && ~/.agents/skills/here-now/scripts/publish.sh dist/ --slug <slug>"
}
}添加到:
package.jsonjson
{
"scripts": {
"deploy": "npm run build && ~/.agents/skills/here-now/scripts/publish.sh dist/"
}
}若要更新现有slug的内容:
json
{
"scripts": {
"deploy": "npm run build && ~/.agents/skills/here-now/scripts/publish.sh dist/ --slug <slug>"
}
}GitHub Pages Deployment (Alternative)
GitHub Pages部署(替代方案)
Use GitHub Pages when you need git-based deployment or already have a GitHub repo set up.
当你需要基于Git的部署方式,或已拥有GitHub仓库时,可使用GitHub Pages。
Prerequisites
前提条件
- GitHub CLI installed ()
gh - Git repository initialized and pushed to GitHub
- 已安装GitHub CLI()
gh - Git仓库已初始化并推送到GitHub
Quick Deploy
快速部署
bash
npm run build && npx gh-pages -d distbash
npm run build && npx gh-pages -d distFull Setup
完整设置流程
- Build the game:
bash
npm run build- Ensure has the correct base path if deploying to a subdirectory:
vite.config.js
js
export default defineConfig({
base: '/<repo-name>/',
// ... rest of config
});- Deploy with GitHub CLI:
bash
gh repo create <game-name> --public --source=. --push
npm install -D gh-pages
npx gh-pages -d dist- Enable GitHub Pages in repo settings (should auto-detect the branch).
gh-pages
Your game is live at:
https://<username>.github.io/<repo-name>/- 构建游戏:
bash
npm run build- 若部署到子目录,请确保设置了正确的基础路径:
vite.config.js
js
export default defineConfig({
base: '/<repo-name>/',
// ... 其余配置
});- 使用GitHub CLI部署:
bash
gh repo create <game-name> --public --source=. --push
npm install -D gh-pages
npx gh-pages -d dist- 在仓库设置中启用GitHub Pages(应自动检测分支)。
gh-pages
你的游戏将在以下地址上线:
https://<username>.github.io/<repo-name>/Automated Deploys
自动化部署
Add to :
package.jsonjson
{
"scripts": {
"deploy": "npm run build && npx gh-pages -d dist"
}
}添加到:
package.jsonjson
{
"scripts": {
"deploy": "npm run build && npx gh-pages -d dist"
}
}Play.fun Registration
Play.fun注册
After deploying, register your game on Play.fun for monetization. Use the skill for integration details.
/game-creator:playdotfunThe deployed URL becomes your when registering:
gameUrltypescript
await client.games.register({
name: 'Your Game Name',
gameUrl: 'https://<slug>.here.now/', // or GitHub Pages URL
maxScorePerSession: 500,
maxSessionsPerDay: 20,
maxCumulativePointsPerDay: 5000
});部署完成后,可在Play.fun上注册你的游戏以实现 monetization(变现)。使用技能查看集成详情。
/game-creator:playdotfun部署后的URL将作为注册时的:
gameUrltypescript
await client.games.register({
name: 'Your Game Name',
gameUrl: 'https://<slug>.here.now/', // 或GitHub Pages URL
maxScorePerSession: 500,
maxSessionsPerDay: 20,
maxCumulativePointsPerDay: 5000
});Other Hosting Options
其他托管选项
- Vercel: (auto-detects Vite)
npx vercel --prod - Netlify: Connect repo, set build command to , publish dir to
npm run builddist - Railway: Use the Railway skill for deployment
- itch.io: Upload the folder as an HTML5 game
dist/
- Vercel:(自动识别Vite)
npx vercel --prod - Netlify:关联仓库,设置构建命令为,发布目录为
npm run builddist - Railway:使用Railway技能进行部署
- itch.io:上传文件夹作为HTML5游戏
dist/
Example Usage
使用示例
Default (here.now)
默认方案(here.now)
/game-deployResult: Builds → publishes via here.now → game live at in seconds. Adds script for future one-command deploys.
dist/https://<slug>.here.now/npm run deploy/game-deploy结果:构建 → 通过here.now发布 → 游戏在数秒内上线至。添加脚本,以便未来一键部署。
dist/https://<slug>.here.now/npm run deployGitHub Pages
GitHub Pages方案
/game-deploy github-pagesResult: Builds with correct base path → pushes to branch → game live at in 1-2 minutes.
gh-pageshttps://<user>.github.io/<game>//game-deploy github-pages结果:使用正确的基础路径构建 → 推送到分支 → 游戏在1-2分钟内上线至。
gh-pageshttps://<user>.github.io/<game>/Troubleshooting
故障排查
here.now 429 rate limit
here.now 429速率限制
Cause: Too many deployments in a short period. here.now has rate limiting on anonymous deployments.
Fix: Wait a few minutes and retry. For frequent deployments, consider using GitHub Pages or Vercel instead.
原因:短时间内部署次数过多。here.now对匿名部署有速率限制。
解决方法:等待几分钟后重试。若需频繁部署,可考虑使用GitHub Pages或Vercel替代。
Anonymous here.now site expired
匿名here.now站点过期
Cause: Anonymous here.now deployments are temporary and expire after a period of inactivity.
Fix: Redeploy with . For persistent hosting, use GitHub Pages ( branch) or Vercel, which don't expire.
npx here.nowgh-pages原因:匿名here.now部署为临时状态,一段时间未使用后会过期。
解决方法:使用重新部署。若需持久托管,可使用GitHub Pages(分支)或Vercel,这些平台不会过期。
npx here.nowgh-pagesGitHub Pages 404 after deployment
GitHub Pages部署后出现404
Cause: Vite's base path doesn't match the GitHub Pages URL structure ().
Fix: Set in . Ensure the branch is selected as the source in the repository's Pages settings. Wait 1-2 minutes for GitHub's CDN to propagate.
/<repo-name>/base: '/<repo-name>/'vite.config.jsgh-pages原因:Vite的基础路径与GitHub Pages的URL结构()不匹配。
解决方法:在中设置。确保仓库的Pages设置中选择了分支作为源。等待1-2分钟,让GitHub的CDN完成传播。
/<repo-name>/vite.config.jsbase: '/<repo-name>/'gh-pagesBlank page after deployment (asset paths)
部署后显示空白页面(资源路径问题)
Cause: Asset paths use absolute URLs () that don't resolve correctly on the deployment host.
Fix: Use relative paths () or configure Vite's option to match the deployment URL. Run locally and test the folder with a local server before deploying.
/assets/..../assets/...basenpm run builddist/原因:资源路径使用绝对URL(),无法在部署主机上正确解析。
解决方法:使用相对路径(),或配置Vite的选项以匹配部署URL。部署前先在本地执行,并使用本地服务器测试文件夹。
/assets/..../assets/...basenpm run builddist/gh-pages push rejected
gh-pages推送被拒绝
Cause: The remote branch has diverged or the force push was blocked by branch protection rules.
Fix: Use if you own the repo and there's no branch protection. If protected, delete the remote branch first: , then redeploy.
gh-pagesgit push origin gh-pages --forcegh-pagesgit push origin --delete gh-pages原因:远程分支已分叉,或强制推送被分支保护规则阻止。
解决方法:如果你拥有仓库且无分支保护,可使用。若有保护规则,先删除远程分支:,然后重新部署。
gh-pagesgit push origin gh-pages --forcegh-pagesgit push origin --delete gh-pagesPre-Deploy Checklist
部署前检查清单
- succeeds with no errors
npm run build - Test the production build with
npm run preview - Remove any debug statements
console.log - Verify all assets are included in the build
- Check mobile/responsive behavior if applicable
- Set appropriate and meta tags in
<title>index.html
- 执行成功,无错误
npm run build - 使用测试生产构建版本
npm run preview - 移除所有调试语句
console.log - 验证所有资源已包含在构建产物中
- 若适用,检查移动端/响应式表现
- 在中设置合适的
index.html和meta标签<title>