Hey friends, Been spinning up an Express API server which is also delivering the Angular6 client side bundle (MEAN6-ish?).I've got no problem with the routing when clients start on the root of the site, however I noticed that "deep links" directly into the app (which the Angular routing should be handling) is not working right...The closest workaround I came up with is to use a wildcard...but just wondering if there's anything I missed or could structure better?If I wanted to add static pages later on, separate from the client handler, could that work as well?// setup our API route app.use('/api/v1', apiRouter); // add the "public" folder to the static handler app.use(express.static(path.join(__dirname, 'public'))); // future request - a static handler for /privacy -- ? app.use('/privacy', (req, res) => { send('privacy'); }); // add the wildcard to catch / as well as deep links to /this/is/a/deep/deep/link app.use('*', express.static(path.join(__dirname, 'public'))); Any tips or advice is appreciated - thanks
Submitted July 29, 2018 at 04:19PM by wazoocakes
No comments:
Post a Comment