I am currently working on a sails app where the routes and static assets are served from the root location, which is functioning properly. However, I am looking to integrate an express middleware to serve these routes and assets from a specific path.
To serve the static assets, I have implemented the following code within the customMiddleware function in config/http.js:
app.use('/my/new/path', express.static(path.join(__dirname, '../client', 'dist')));
By including the above code snippet, I successfully managed to load the static files from both the root and /my/new/path locations.
Now my challenge lies in handling the routes using sails and incorporating them via express middleware using app.use. For instance, the default home route '/' set in my config/routes-client.js file poses an issue as I prefer not to modify it there. Instead, I intend to use something similar to the example below, which is usually employed in a standard node/express application:
app.use('/my/new/path', routes); --> where 'routes' represents my server routes
Is there a method to incorporate an express middleware that serves sails routes on a designated path?