{"slug":"eo-umami","title":"WTF？！直接将Umami部署到EdgeOne Pages？扔掉VPS！直接跑在云函数！","description":"我们都知道，EdgeOne Pages有个完整的Node.js环境，那Umami是Next.js也基于Node.js，那我们是不是可以...","coverImage":"https://b.acofork.com/img/eo-umami-eo-umami-1.webp","coverWidth":217,"coverHeight":155,"date":"2026-01-19","tags":["服务器"],"pinned":false,"wordCount":514,"html":"<h2 id=\"原理探寻\">原理探寻</h2><p>由于 <strong>Umami</strong> 使用的是 <strong>SSR</strong> ，我原以为EdgeOne Pages不支持该模式，尝试部署后发现最大的问题在于</p>\n<div class=\"markdown-code\" data-language=\"text\"><div class=\"markdown-code-header\"><span class=\"markdown-code-language\"><svg class=\"code-language-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z\"></path><path d=\"M14 2v5a1 1 0 0 0 1 1h5\"></path><path d=\"M10 9H8\"></path><path d=\"M16 13H8\"></path><path d=\"M16 17H8\"></path></svg><span>text</span></span><button type=\"button\" class=\"code-block-copy\" aria-label=\"复制代码\" title=\"复制代码\"><svg class=\"code-block-copy-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"></rect><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"></path></svg></button></div><pre><code class=\"hljs language-text\">Error: SSR functions package size exceeds 128MiB limit (157MiB)</code></pre></div><p>也就是说，EdgeOne Page是支持SSR程序的，只是Umami构建后的函数太大了，那么我们的思路就很清晰了，只需要裁切一些代码即可</p>\n<p>那么该项目就应运而生了 <a href=\"https://github.com/afoim/umami\" target=\"_blank\" rel=\"noopener noreferrer\">afoim/umami: Umami is a modern, privacy-focused analytics platform. An open-source alternative to Google Analytics, Mixpanel and Amplitude.</a> </p>\n<p>我将Umami v3中的无关紧要的东西，如 <code>像素统计</code> <code>链接统计</code> <code>团队</code> <code>地理位置文件</code> 删去了，最终可以在EO上部署一个残血版的Umami</p>\n<p>至于数据库，我用的是 <a href=\"https://supabase.com/\" target=\"_blank\" rel=\"noopener noreferrer\">https://supabase.com/</a> 需要注意，连接方式不能用 <code>Direct Connection</code>\n<img src=\"https://b.acofork.com/img/eo-umami-eo-umami-2.webp\" alt=\"\" width=\"1048\" height=\"596\" loading=\"eager\" decoding=\"async\" /></p>\n<p>Demo： <a href=\"https://eo-umami.acofork.com/share/rC995W8J6CT4uLDo\" target=\"_blank\" rel=\"noopener noreferrer\">Umami</a></p>\n<p>视频： <a href=\"https://www.bilibili.com/video/BV1JiqSBaEY1/\" target=\"_blank\" rel=\"noopener noreferrer\">https://www.bilibili.com/video/BV1JiqSBaEY1/</a></p>\n<p>唯一的缺陷，无法获取用户地区（原逻辑有个高达60M的本地Geo文件）\n<img src=\"https://b.acofork.com/img/eo-umami-eo-umami.webp\" alt=\"\" width=\"1286\" height=\"1144\" loading=\"lazy\" decoding=\"async\" /></p>\n<h2 id=\"上手部署\">上手部署</h2><ol>\n<li>Fork 该仓库 [<a href=\"https://github.com/afoim/umami\" target=\"_blank\" rel=\"noopener noreferrer\">afoim/umami: Umami is a modern, privacy-focused analytics platform. An open-source alternative to Google Analytics, Mixpanel and Amplitude.</a>](<a href=\"https://github.com/afoim/umami-edgeonepages/tree/main\" target=\"_blank\" rel=\"noopener noreferrer\">https://github.com/afoim/umami-edgeonepages/tree/main</a>)</li>\n<li>连接到EdgeOne Pages，但先别点部署</li>\n<li>填写环境变量 <code>DATABASE_URL</code> 从Supbase中拿，类似于 <code>postgresql://postgres.kupggtyqiaepzvjqbboy:[YOUR-PASSWORD]@aws-1-ap-northeast-1.pooler.supabase.com:5432/postgres</code></li>\n<li>绑定你的域名，访问并登录。用户名： admin | 密码：umami</li>\n</ol>\n<h2 id=\"疑难解答\">疑难解答</h2><p><del>内部重定向貌似出了问题，如果你想要访问设置更改你的管理员密码请手动前往 <code>/settings/preferences</code></del> 他们解决了这个问题，但是...</p>\n<p>但是有个新问题，就是POST请求全被吃了，目前代码暂时将所有POST请求改为了GET请求。我们在 <strong>Main</strong> 分支发布了全GET请求的版本，保证普通用户可用</p>\n<p><strong>master 分支目前提供给腾讯当作试验场使用，会暴露很多敏感信息，别用</strong></p>\n","toc":[{"id":"原理探寻","text":"原理探寻","depth":2},{"id":"上手部署","text":"上手部署","depth":2},{"id":"疑难解答","text":"疑难解答","depth":2}]}