To make both the server and the client run in the same port following procedure needs to be followed,
create a folder "build" in the client folder
run the command npm run build in the /client folder and direct the executables into the /client/build directory
This executables in the /client/build shall be injected as a middleware to the express framework router stack.
We are using OAS3tools for the express framework.
The custom routes shall be included at any position before router and after express json middlewares.
const stack = app._router.stack;
const lastEntries = stack.splice(app._router.stack.length - 2); // The number of middleware we added is 2 in this case.
const firstEntries = stack.splice(0, 9); // Adding the middleware after the cookieParser
app._router.stack = [...firstEntries, ...lastEntries, ...stack];
console.log(app._router.stack);
To make both the server and the client run in the same port following procedure needs to be followed, create a folder "build" in the client folder run the command npm run build in the /client folder and direct the executables into the /client/build directory This executables in the /client/build shall be injected as a middleware to the express framework router stack.
We are using OAS3tools for the express framework. The custom routes shall be included at any position before router and after express json middlewares.