You can not select more than 25 topics 
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long. 
		
		
		
		
		
			
	
	
		
			
	
		
			This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
		 
	
		
		
			
				
				
					
						
						
						
							---
 
						
						
						
							layout: post
 
						
						
						
							title: 使用CloudFlare Workers做一些有趣的功能
 
						
						
						
							tags: [CloudFlare, Workers]
 
						
						
						
							---
 
						
						
						
							
 
						
						
						
							  挺不错, <!--more-->     
 
						
						
						
							  
 
						
						
						
							# 起因
  
						
						
						
							,  
						
						
						
							  虽然我很早就在用CloudFlare, , , , , , , , ,  
						
						
						
							  
 
						
						
						
							# 首先给自己搭个反代
  
						
						
						
							, , ,  
						
						
						
							  代码如下:
 
						
						
						
							```javascript
  
						
						
						
							addEventListener ( "fetch" ,  event  =>  { 
 
						
						
						
							  let  url  =  new  URL ( event . request . url ); 
 
						
						
						
							  url . hostname  =  "mabbs.github.io" ; 
 
						
						
						
							  event . respondWith ( fetch ( new  Request ( url ,  event . request ))); 
 
						
						
						
							}); 
 
						
						
						
							``` 
 
						
						
						
							  看起来代码好像更简单了, , ,  
						
						
						
							  最终做出来的网址如下: < https: // blog . mayx . workers . dev />  ,这也算是我博客的另一个为了在国内能访问的域名吧……如果自己有域名的话可以设置路由把其他域名绑在上面。   
 
						
						
						
							  不过CloudFlare Workers也有一些缺陷, , , , , , , ,  
						
						
						
							
 
						
						
						
							# 给自己的网站搭一个Status Page吧
  
						
						
						
							, , , ,  
						
						
						
							  这个东西支持一键部署, , ,  
						
						
						
							  
 
						
						
						
							# 其他玩法
  
						
						
						
							, , , , , , ,  
						
						
						
							  如果自己有能力开发的话利用那个KV存储其实想开发什么网站都可以, , ,  
						
						
						
							  比如我之前开发的[图片机器人](/2021/02/23/picbotpro.html)、[Server酱自制版](/2021/02/26/serverchancorp.html)等等都可以用CloudFlare Workers重写。   
 
						
						
						
							  像这样甚至自己写一个论坛都没问题, , ,  
						
						
						
							  
 
						
						
						
							# 总结
  
						
						
						
							( , ) , ? ( , ) ? , , , , , , , , , , , ,