This document describes how to quickly deploy a local Nuxt.js SSR project to the cloud through a web function.
This document mainly describes how to deploy in the console. You can also complete the deployment on the command line. For more information, please see Deploying Framework on Command Line.
webfuncin the search box to filter function templates, select Nuxt.js Framework Template, and click Next as shown below:
As the Nuxt.js framework needs to be rebuilt before each deployment, please be sure to update the code locally and run
buildagain before deploying.
The Node.js runtime environment has been installed locally.
Refer to Installation to install and initialize your Nuxt.js project:
npx create-nuxt-app nuxt-app
In the root directory, run the following command to directly start the service locally.
cd nuxt-app && npm run dev
http://localhost:3000 in a browser, and you can access the sample Nuxt.js project locally.
Next, perform the following steps to make simple modifications to the initialized project, so that it can be quickly deployed through a web function. The project transformation here is usually divided into the following two steps:
The specific steps are as follows:
scf_bootstrapbootstrap file in the project root directory and add the following content to it (which is used to start services and specify the bootstrap port):
- Here is only a sample bootstrap file. Please adjust the specific operations according to your actual business scenario.
- The sample uses the standard node environment path of SCF. When debugging locally, you need to change it to your local path.
755is required for it to start normally. Below is the sample code:
When you access the URL, the access may fail due to frontend routing. Therefore, you need to remove the
/releasepath when accessing.
After the deployment is completed, you can quickly access and test your web service in the SCF console and try out various features of SCF, such as layer binding and log management. In this way, you can enjoy the advantages of low cost and flexible scaling brought by the serverless architecture: