Skip to content

Alist前端如何部署到CloudFlare Pages上? #6680

Answered by Simonzhang8
Simonzhang8 asked this question in Q&A
Discussion options

You must be logged in to vote

现在已经修改标题了,大家看清楚是Alist的前端部署到Cloudflare Pages,实现的效果是前后端的分离,后端暂时还是需要依赖服务器的。原来的标题说的不是很清楚,造成部分朋友误解了认为Alist可以不依赖服务器直接在Pages上使用。

我找到了办法。直接把alist-web这个项目fork一下,把里面index.html里的api填入自己的alist网址
注意是Alist原本的网址(服务器反代后的地址,或者服务器的ip地址但cf要求80或443端口),不是Pages的地址!!!换句话说Cloudflare Pages只是给Alist套壳了一个前端,本身不能独立运行(如果有大佬有办法不依赖服务器运行后端的话欢迎交流)
然后在cloudflare pages里运行npm run build就可以了。不过现在有两个问题,一个是编译出来的是英文版的没有中文,还有一个是@manage设置里的所有个性化设置比如head,body,logo这些都无效了

这个比较适合有分开部署前后端,或者不想手动编译前后端但又想自定义前端,或者希望将更多静态资源托管到cdn等需求的用户。同理,类似的方法也可以部署到Github Pages(目前测试有些问题,可能需要大神帮助)、Netlify、Vercel或虚拟主机等平台上(Netlify和Vercel与CF Pages一样也可以自动编译,这里用了CF Pages是因为Cloudflare无流量限额,Vercel刚才试了也行(注意需要多一句pnpm install),大家可以根据自己喜好选择托管平台;虚拟主机不能自动编译,需要本地编译完后扔…

Replies: 10 comments 31 replies

Comment options

You must be logged in to vote
5 replies
@Simonzhang8
Comment options

@Simonzhang8
Comment options

@Simonzhang8
Comment options

@Simonzhang8
Comment options

@ix520
Comment options

Comment options

You must be logged in to vote
4 replies
@Simonzhang8
Comment options

@anwen-anyi
Comment options

@ix520
Comment options

@Simonzhang8
Comment options

Answer selected by Simonzhang8
Comment options

You must be logged in to vote
5 replies
@Simonzhang8
Comment options

@anwen-anyi
Comment options

@Simonzhang8
Comment options

@Simonzhang8
Comment options

@anwen-anyi
Comment options

Comment options

You must be logged in to vote
2 replies
@Simonzhang8
Comment options

@xingnengmao666
Comment options

Comment options

You must be logged in to vote
1 reply
@Simonzhang8
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@ix520
Comment options

@Simonzhang8
Comment options

@ix520
Comment options

Comment options

You must be logged in to vote
11 replies
@alan16742
Comment options

@122cygf
Comment options

@alan16742
Comment options

@122cygf
Comment options

@alan16742
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
9 participants