Hi friends, Just trying to get the routing configured correctly in my Express app to return some static pages for some requests and my Angular5 application on a specific path. It's very close to all working together, but I'm running into an issue where the javascript source files (eg. the app) being requested from within my public/app/index.html are being handled by Express and thus returning the 404 response...Any ideas? Is there a simple thing I'm missing? Thanks for any help!app.use(express.static('./public')); app.get('/', function(req, res) { res.render('pages/index'); }); app.get('/about', function(req, res) { res.render('pages/about'); }); // Set our api routes app.use('/api/v1', api); // anything under /app/ is using the angular-cli produced folder app.get('/app/', (req, res) => { // this "works"...but the JavaScript files being requested from within // the index.html are also being handled by Express... res.sendFile(path.join(__dirname, './public/app/index.html')); }); // 404 Route (ALWAYS Keep this as the last route) app.get('*', function(req, res){ res.render('pages/404'); });
Submitted May 10, 2018 at 08:08AM by wazoocakes
No comments:
Post a Comment