DEV Community

Discussion on: Deploy a fullstack NX workspace on Heroku

Collapse
 
cdnfs profile image
CodingSpiderFox

There is a section "Update apps/api/src/main.ts to serve the built nx-fullstack client once built"

It is not clear to me what to change in the file for that step

Collapse
 
ihaback profile image
ihaback

Here you need to update the express to serve the static build of the frontend app. It is these lines that you need to add

const CLIENT_BUILD_PATH = path.join(__dirname, '../nx-fullstack');

const app = express();
app.use(express.static(CLIENT_BUILD_PATH));
Enter fullscreen mode Exit fullscreen mode

and

// This route needs to come last after all your other api routes
app.get('*', (request, response) => {
  response.sendFile(path.join(CLIENT_BUILD_PATH, 'index.html'));
});
Enter fullscreen mode Exit fullscreen mode