如何在Nginx中使用vue.js?

nginx Vue.js

米亚猴子

2020-03-13

我想使用Nginx作为我的Web服务器和我自己的Dropwiward REST API使用Vue.js构建一个单页应用程序。此外,我使用Axios调用我的REST请求。

我的nginx配置看起来像

server {
    listen       80;
    server_name  localhost;

    location / {
        root     path/to/vue.js/Project;
        index    index.html index.htm;
        include  /etc/nginx/mime.types;
    }
    location /api/ {
        rewrite ^/api^/ /$1 break;
        proxy_pass http://localhost:8080/;
    }
}

目前,我可以打电话给我,localhost/api/path/to/rescource以从后端获取信息。

我使用到目前为止已经运行的HTML和javascript(vue.js)构建了前端。但是,当我要构建单页应用程序时,大多数教程都提到了node.js。我该如何使用Nginx?

第1466篇《如何在Nginx中使用vue.js?》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

0个回答

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android