Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Tobbeman
@Tobbeman
aaah
Eric M. Dantas
@ericmdantas
when deploying, the server will try to catch stuff in the dist folder
client/dist, that is
Tobbeman
@Tobbeman
Super noob question, how does it know if I have deployed or not?
Eric M. Dantas
@ericmdantas
enviroment variables
if you're deploying to heroku, for example
you can set the NODE_ENV var to production
and the server side of the app will catch it and read the static stuff from a different folder
Tobbeman
@Tobbeman
Ah
Let me test
Still same problem
Maybe deploy was wrogn word
Eric M. Dantas
@ericmdantas
do you have the dist folder now?
Tobbeman
@Tobbeman
When used on local computers it works fine, even between them on same wifi
inside client, yes
Eric M. Dantas
@ericmdantas
right
and you're trying to deploy to which host?
Tobbeman
@Tobbeman
but when moving the project to an vps
Eric M. Dantas
@ericmdantas
heroku?
ah, ok
Tobbeman
@Tobbeman
I can't access it without it showing the error above
Eric M. Dantas
@ericmdantas
so you'll have to set the enviroment var there
I see
the thing is
the app doesn't know it's in "prod", because you haven't set it to do so
Tobbeman
@Tobbeman
hmmm
Eric M. Dantas
@ericmdantas
you'll have to set it to "production" and the same thing for the db connection string
Tobbeman
@Tobbeman
I'm using an docker container
the containers running the site locally does not have an env either
Eric M. Dantas
@ericmdantas
when it doesn't have one, it assumes you're on dev
you're using Mongo too?
Tobbeman
@Tobbeman
yep!
I need to set NODE_ENV then?
how to I set the db connection tho?
oh wait, I think I got it
fug!
same error...
Eric M. Dantas
@ericmdantas
for the vps you'll need to do it
same for the db connection
Tobbeman
@Tobbeman
Yee, I set both
Eric M. Dantas
@ericmdantas
those are the things that change from the local machine to the one everybody can see
let me build an angular2 project and see if I get any error
Eric M. Dantas
@ericmdantas
so, what I did was:
  • added process.env.NODE_ENV = "production" in my server/server.js file
  • added a <h1>!</h1> tag in the index.html inside the client/dist folder
  • ran node server/index
  • checked the https://localhost:3333 and everything is showing just fine
Tobbeman
@Tobbeman
hmm
well, localhost works for me to :P
I'll try that tho!
Tobbeman
@Tobbeman
Get another set of errors :/
GET /config.js?rev=@@hash 404 6.143 ms - 33
GET /app.module 404 0.980 ms - 23
GET /@angular/platform-browser-dynamic/ 404 0.602 ms - 47
in console
where did you place the <h1>!<h1>?