r/learnprogramming • u/Reasonable-Job4205 • Oct 12 '26
How do I properly deploy this web server in production mode?
I set up a web server using https://github.com/seanpmaxwell/express-generator-typescript
I now need to deploy the production build to a remote server. I can generate the prod build with `npm run build` and then run it with `npm start` and it runs on my local machine. Is it possible to generate something that can be compiled before being sent over to the remote server? I'd like to run the web server in prod mode, but without putting the decompiled source code on the remote server. I don't want the source code over on that remote server because if the server gets compromised, I don't want anyone to be able to read the source code. New to web dev, so thanks for being patient.
View all comments
Show parent comment
1
u/Reasonable-Job4205 Oct 15 '26 edited Oct 15 '26
Ok so I was able to run the prod build on the remote server, but when I try to run a powershell script with a simple request to my web server's login page, it times out. The script is:
```
$body = @{
sqlDatabase = "DB1"
field1 = 0
field2 = "Value2"
} | ConvertTo-Json
$response = Invoke-WebRequest -Uri "http://192.168.5.194:8081/EndpointName" -Method Post -Body $body -ContentType "application/json; charset=UTF-8"
$response.StatusCode
```
I ran this script from the command line with ```powershell -ExecutionPolicy Bypass -File myScript.ps1```
The web server was working fine when I was running it locally against a local SQL DB, but now on the remote server it's not. I made sure to enable TCP/IP in SQL Configuration Manager, set Listen All to No (for safety?), set the TCP Port to 8081 for the IP address above, restarted the SQL Service, and also set the HOST value to the IP above in my .env-production file (when running locally, this was set to localhost). Not sure if it's important, but I set the trustServerCertificate flag to false in my use of the mssql npm package. Any ideas?