当前位置:网站首页>5 minutes to quickly launch web applications and APIs (vercel)
5 minutes to quickly launch web applications and APIs (vercel)
2022-06-23 15:32:00 【Code Taoist】
Last week, a kid asked me how to build one quickly Web application , I want to practice my hand , Do not consider purchasing servers . I recommended the popular one some time ago
Vercel, Next I'll show you 5 Minutes to go !
Vercel
Vercel You can understand it as a deployment tool , Support the deployment of static web pages and Node service , After deployment, you can also access the generated domain name https.

More than that , Except for his own son Nextjs outside , It also provides a lot of template support , for example :
- Nuxt.js: Vue Of SSR frame
- Hexo: Quickly generate blog sites
- Remix: An edge native full stack JavaScript frame
- Templates up to 30 Kind of ..

Vercel The core of the system mainly includes development 、 preview 、 Deploy . By authorization Github to Vercel after , You can select the project we want to deploy Github Warehouse , The project automatically updates the deployment . Next, I'll teach you to do it in one step !
1. Select template
This demonstration practice framework , I choose vercel My son
Next.js. He provided many cases , Here I choose one Template :with-vercel-fetch. To achieve a simple SSR service .

stay Vercel Create a project , You'll find that Vercel Follow Github It can be linked ! Support to help you create a private Github Warehouse , The essence is similar Github Page, however Github Page Your access speed is too slow . this Vercel Directly kill .

stay Vercel After helping us create the warehouse , Yes Demo Make some adjustments in the warehouse

Here I am fetch Of API The interface uses Apifox Provided Cloud Mock The function of , You can adjust the interface data without setting up a set of back-end services !
stay Apifox Of Web Create an interface in version , Then, the interface return fields are Mock Customize ( Support customization Mock data )
This is a cloud I customized Mock Interface https://mock.apifox.cn/m1/388694-0-default/star/list

Interested friends can experience Apifox
2. Release
After completing the above steps ,vercel The deployment phase will be automatically executed , And generate the access domain name , At the same time, you can see the preview effect of the application !

And later your github Warehouse only main Any changes to the branch ,vercel Can automatically trigger Deploy Deploy .
For a final visit, we use vercel Deployed pages

Ah Le classmate : Well, if I want to replace the domain name ? Do not use the domain name assigned by him
Tolerable , If you want to bind an independent domain name , You can operate view domain Perform custom domain name binding , Finally, go to the domain name resolution to resolve CNAME To cName.vercel-dns.com

3. Other deployment methods
Vercel Provide deploy Hook, You can vercel Configuration on the control panel in the created project deploy hook, You just need to fill in deploy( Deploy ) The branch of git branch, And the corresponding hook name ( Customize ), You can configure an independent trigger mode .
The configuration is as follows

Finally, we initiate the request on the command line , You can trigger the construction and deployment of the project . Is it convenient !
curl -X POST https://api.vercel.com/v1/integrations/deploy/prj_GeziGEUiSxxxxxx/tV4Wm5MO2j
4.Serverless relevant
Vercel It is essentially a zero configuration Serverless Deployment platform , What is Serverless Well ? You can look at the previous article written by tree jam : You learn BFF and Serverless Did you?

Vercel Realization Serverless The bottom layer is based on AWS( Amazon cloud ) Of lambda This mountain . We use it vercel Can deploy Serverless Interface , Next, we will develop a simple Serverless API
Execute in a local project
1. npm install [email protected] -g ( Global installation )
2. vercel login
3. vercel ( In addition to initialization .vercel file It can also trigger the Deploy Deploy )

After completing the appeal operation , We can start work ! We found that vercel The command will help us create .vercel Folder , Then we create a with the directory api Folder , And create a new one " Cloud functions " message, Let's look at the code structure !

Finally, re execute vercel, You can deploy this Serverless API 了 ! We'll use Apifox debugged ! Successfully returns !

边栏推荐
猜你喜欢

The team of China University of Mines developed an integrated multi-scale deep learning model for RNA methylation site prediction

Arrays in JS

K8s-- deploy stand-alone MySQL and persist it
![[opencv450] salt and pepper noise demo](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[opencv450] salt and pepper noise demo

The work and development steps that must be done in the early stage of the development of the source code of the live broadcasting room

WebService接口发布和调用

Important knowledge of golang: sync Once explanation

嵌入式软件架构设计-程序分层

A transformer can only convert alternating current. How can I convert direct current?

2021-05-08
随机推荐
进销存软件排行榜前十名!
Sfod: passive domain adaptation and upgrade optimization, making the detection model easier to adapt to new data (attached with paper Download)
力扣解法汇总513-找树左下角的值
js遍历数组(用forEach()方法)
他山之石 | 微信搜一搜中的智能问答技术
JSR303数据校验
基因检测,如何帮助患者对抗疾病?
Volatile~ variables are not visible under multithreading
山东:美食“隐藏款”,消费“扫地僧”
【云驻共创】智能供应链计划:提升供应链决策水平,帮助企业运营降本增效
Why is Xiaomi stuck in the chip quagmire?
打印内存站信息
Effect evaluation of regression model under credit product quota pricing scenario
golang 重要知识:waitgroup 解析
VIM backup history command
Logistics trade related
Convert JSON file of labelme to coco dataset format
Sectigo(Comodo)证书的由来
How to solve the problem that iterative semi supervised training is difficult to implement in ASR training? RTC dev Meetup
[opencv450] salt and pepper noise demo