angularjs - 更改平均应用程序的根

标签 angularjs node.js express mean-stack

我正在开发平均应用程序,我需要从另一个网址(如(“/myApp”)而不是root加载我的html,css,那么如何才能得到这个呢?我的意思是我想启动我的应用程序表单 url“localhost:3003/myApp”,默认情况下它在“localhost:3003/”上运行

我的配置文件是

 var express = require('express'),
        routes = require('./routes'),
        fs = require('fs'),
        bodyParser = require('body-parser'),
        router = express.Router();
        var port = 80;
        var app = module.exports = express(); 

        // Configuration
         //app.use(router);

        app.use(bodyParser());
        //app.use(express.methodOverride());
       app.use(express.static(__dirname + '/dev'));
        //app.use(express.compress());


    app.all('*', function (req, res, next) {
        res.header("Access-Control-Allow-Origin", "*");
        res.header("Access-Control-Allow-Headers", "Content-Type, Authorization, Content-Length,X-Requested-With");
        res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
        next();
    })

    router.get('/', routes.index);

    router.get('/template/:name', routes.partials);

    // JSON API
    router.get('/api/name', routes.name);

    // redirect all others to the index (HTML5 history)
    router.get('*', routes.index);

    app.use('/', router);


       app.listen(3003, function(){
                console.log("Express server listening on port mode");
            });

    process.on('uncaughtException', function (err) {
        console.log((new Date).toUTCString() + ' uncaughtException:', err.message)
        console.log(err); //process.setMaxListeners(0);
       // process.setMaxListeners(0);
        process.exit(1)
    })

最佳答案

更改:app.use('/', router);app.use('/myApp', router);

关于angularjs - 更改平均应用程序的根,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29795970/

相关文章:

java - Rails 和 Java 上的 Angular 和 Rest 服务之间的 session

css - Less:@import url 在缩小后使用 http 而不是 https

node.js - 如何编写用于文件上传的 Node.js express API?

node.js - Visual Studio 2015 预览版 - Apache Cordova 构建错误

Node.JS 和 Express : get application host without request

reactjs - 使用 Express 后端将 create-react-app 部署到 heroku 在浏览器中返回无效的主机 header

javascript - 仅当表单脏时才显示添加按钮

javascript - 不使用 arraybuffer 检索二进制数据

javascript - Bluebird 的 promise 和领域

javascript - NodeJS 中的访问计数器