I'm been trying to deploy my SAP Spartacus app to Heroku.
In the scripts section of my package.json I have added "start": "node server.ts",
And this is the server.ts I'm using:
const express = require('express');
const path = require('path');
const app = express();
app.use(express.static(__dirname + '/src/spartacus-mystore'));
app.get('/*', function (req,res){
res.sendFile(path.join(__dirname+
'/src/spartacus-mystore/index.html'));});
app.listen(process.env.PORT || 8080);
I still donno what, but something is wrong with this file. In the Heroku's console I see everything is correct and the app was successfully deployed but when I reach it I just see a blank page.
I solved this following this steps:
I added "heroku-postbuild": "ng build --prod"
to scripts section in package.json.
I copied @angular/compiler, @angular/compiler-cli, @angular-devkit/build-angular and @angular-devkit/schematics fron devDependencies to dependencies
I change my serve.ts according to Erik's comment
const express = require('express'); const path = require('path'); const app = express(); app.use(express.static(__dirname + '/dist/mystore/browser')); app.get('/*', function (req,res){ res.sendFile(path.join(__dirname+ '/dist/mystore/browser/index.html'));}); app.listen(process.env.PORT || 8080);
Now it's working https://spartacus-mystore.herokuapp.com/electronics-spa/en/USD/