我有一个已部署到CloudFlare页面的Sveltekit网站,问题是,当我使用静态适配器部署该应用程序并尝试访问该网站时,它说“找到网址没有网页”,但是当我使用CloudFlare Adapter时它可以成功地工作,因此我打算使用CloudFlare适配器,但我注意到“今天的功能请求”的数量正在增加,尽管我的应用程序没有任何功能(某些内容如何将每个请求视为服务器函数),那么什么我在这里做错了吗?
I have a sveltekit website that I deployed to cloudflare pages, the problem is that when I deploy the app with the static adapter and try to visit the site it says "No webpage was found for the web address" but when I use the cloudflare adapter it works successfully, so I was intending to use the cloudflare adapter but I noticed that the number of "Functions requests today" was increasing although my app does not have any functions (some how every request is counted as a server function), So what am I doing wrong here?
发布评论
评论(1)
运行
NPM运行构建
构建目录是否包含index.html
文件?如果不是,您可能需要指定prerender.default = true
so:使用
/build
Directory,其中包含index.html
。接下来只需按照CloudFlare页面文档的说明进行部署 https:// https:// https:/// developers.cloudflare.com/pages/framework-guides/deploy-anything/这些说明包括以下内容:
'
通过登录 Cloudflare仪表板> 帐户主页> 页面并选择创建一个项目。选择您创建的新的GITHUB存储库,然后在设置中构建和部署部分,提供以下信息:
MAIN
< your_build_dir>
与许多框架指南不同,网站的构建命令和构建目录将完全自定义。如果您不需要构建步骤,请留下构建命令字段空,并指定构建输出目录。构建输出目录是您的应用程序内容所处的位置。
配置网站后,您可以开始第一次部署。您的自定义构建命令(如果提供)将运行,并且页面将部署您的静态站点。
有关将第一个站点部署到CloudFlare页面的完整指南,请参阅。
部署网站后,您将在
*。页面.dev
上收到一个唯一的子域。 CloudFlare页面将自动重建您的项目并部署该项目。您还将可以在新的拉请请求上访问预览部署,因此您可以在部署将它们部署到生产之前预览网站上的更改外观。从这些说明中,您似乎只需要将
生产分支
设置为main
分支(或者您想要部署的分支)和构建输出目录到
构建
(除非您的svelte.config.json
在另外指定)。确保您的.gitignore不包括/build
目录,除非您要使用build command
config config,然后继续进行。When you run
npm run build
does the build directory contain anindex.html
file? If not you may need to specifyprerender.default = true
like so:With that you should get a
/build
directory that containsindex.html
. Next just follow the instructions from Cloudflare Pages documentation for deploying your site https://developers.cloudflare.com/pages/framework-guides/deploy-anything/These instructions include the following:
Deploying with Cloudflare Pages
Deploy your site to Pages by logging in to the Cloudflare dashboard > Account Home > Pages and selecting Create a project. Select the new GitHub repository that you created and, in the Set up builds and deployments section, provide the following information:
main
<YOUR_BUILD_COMMAND>
<YOUR_BUILD_DIR>
Unlike many of the framework guides, the build command and build directory for your site are going to be completely custom. If you do not need a build step, leave the Build command field empty and specify a Build output directory. The build output directory is where your application's content lives.
After configuring your site, you can begin your first deploy. Your custom build command (if provided) will run, and Pages will deploy your static site.
For the complete guide to deploying your first site to Cloudflare Pages, refer to the Get started guide.
After you have deployed your site, you will receive a unique subdomain for your project on
*.pages.dev
. Cloudflare Pages will automatically rebuild your project and deploy it. You will also get access to preview deployments on new pull requests, so you can preview how changes look to your site before deploying them to production.From these instructions it looks like you only need to set
Production branch
to yourmain
branch (or which ever branch you would like deployed) andBuild output directory
tobuild
(unless otherwise specified in yoursvelte.config.json
). Ensure that your .gitignore does not include the/build
directory unless you want to use theBuild command
config then go ahead and do that.