1

I am working on mean application,i have a requirement to load my html,css from another url like("/myApp") rather then root, so how can get this? i mean i want to start my app form url "localhost:3003/myApp", bydefault it is running on "localhost:3003/"

My configuration file is

 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)
    })
syymza
  • 679
  • 1
  • 8
  • 23
Prabjot Singh
  • 4,491
  • 8
  • 31
  • 51
  • possible duplicate of [Is it possible to set a base URL for NodeJS app?](http://stackoverflow.com/questions/4375554/is-it-possible-to-set-a-base-url-for-nodejs-app) – paul Apr 22 '15 at 11:30

1 Answers1

0

Change: app.use('/', router); to app.use('/myApp', router);

paul
  • 21,653
  • 1
  • 53
  • 54