IIS deploys vue front-end process (including IIS and related configuration and installation), problems and errors encountered in deployment (undertake vueconfig.js global configuration environment variables, cross-domain problems)

Table of contents

1. IIS usage installation.

2. Deployment preparations

3. Deploy the front end (mainly vue)

4. Problems and errors

1. HTTP error 404.0 - Not Found (routing entry needs to be rewritten)

2. The request cannot be called (need to rewrite the request address)

3. The address shows undefined


1. IIS usage installation.

The first step is to open the " Control Panel " and click " Network and Internet ".

Step 2: Click " Programs " on the left, and then click " Turn Windows features on or off ".

 The third step is to find " internet information services " or " Internet information services ", check all, as shown in the figure, then click OK, and wait for the installation.

 After the installation is complete, search for " IIS " in the task bar and open it. The installation is now complete.

2. Deployment preparations

Just downloading IIS is not enough. To deploy the front end, we need the " Web Platform Installer " in IIS (click to jump to install). After the download is complete, it is as follows.

 Next, we need to download two modules in  the " Web Platform Installer ", namely URLRewrite (click to jump to install) and Application Request Routing (click to jump to install), the installation process and completion are shown in the figure.

 Then, double-click " Application Request Routing ", click " Server Proxy Settings... " in " Proxy " in the right operation , and then tick " Enable proxy "

3. Deploy the front end (mainly vue)

The first step is to right-click " Sites " and click " Add Site "

 The second step, as shown in the figure.

 The third step is to double-click the website you created and deployed. In the operation on the right, click " Browse Website " to access successfully, as shown in the figure below.

 At this point, the deployment is only deployed and can be accessed, but there are still many problems and errors, and the errors will be resolved next.

4. Problems and errors

1. HTTP error 404.0 - Not Found (routing entry needs to be rewritten)

After the above deployment, we will find that if we refresh the page or jump to the route , an error will be   reported

HTTP Error 404.0 - Not Found

The resource you are looking for has been deleted, renamed, or temporarily unavailable.

Most likely cause:

  • The specified directory or file does not exist on the web server.
  • URL misspelled.
  • A custom filter or module (such as URLScan) is restricting access to this file.

Things to try:

  • Create content on the web server.
  • Check the browser URL.
  • Create a trace rule to trace failed requests with this HTTP status code and see which module is calling SetStatus.

Detailed error information:

module    IIS Web Core
notify    MapRequestHandler
handler    StaticFile
error code    0x80070002
requested URL    http://xxx.xxx.x.xxx/login
physical path    C:\Users\Admin\Desktop\aa\dist\login
login method    Anonymous
login user    Anonymous

details:

This error indicates that the file or directory does not exist on the server. Please create the file or directory and try the request again.

 This error is caused by a wrong routing entry, mainly because there is no routing entry determined . At this time, we need to use  URLRewrite to rewrite the routing entry to ensure that each routing request can enter from the main entry of index.html to ensure routing The accuracy, after the simple configuration here, you can refresh and route jump, the details are as follows.

(1). Click " URL Rewrite ", and then click " Add Rule " in the operation

 (2). Edit the rules, restart the deployed website after completion, click to browse the website, and successfully resolve the error.

2. The request cannot be called (need to rewrite the request address)

The rewriting here is based on the rewriting in my devServer.proxy , the regular expression just needs to replace api with the rewriting name you defined

3. The address shows undefined

If the following problems occur, first determine whether the request rewriting rule is set and enabled. If it is enabled, it may be because the port of the deployment address is occupied.

The modification operation is as follows, so that the request can be called normally afterwards.

Guess you like

Origin blog.csdn.net/weixin_43721856/article/details/128248201