Spent hours trying to figure out why it worked locally and not in Heroku. 503 Error in chrome, PostgreSQL error: no pg_hba.conf entry for host. Here is the fix.... Heroku needs this line when creating the pool: ssl: { rejectUnauthorized: false, }, This will fix the Heroku problem but break the dev server. Create a new pool conditionally for production/dev like this: const pool = process.env.NODE_ENV === "production" ? new Pool({ connectionString: prodConfig, ssl: { rejectUnauthorized: false, }, }) : new Pool({ connectionString: devConfig, });
This is the code i used to ensure it worked on local server too const pool = process.env.NODE_ENV === "production" ? new Pool({ connectionString: proConfig, ssl: { rejectUnauthorized: false, }, }) : new Pool({ connectionString: devConfig, });
You are amazing. Thank you so much, you saved my day for real I finished the whole tutorial and was super confused at why it would not work. Thank you so much
Another great tutorial, thank you Henry, suppose name from package author info :)! I have watched the PERN tutorial prior to this tutorial, it was also great. I was looking how to deploy my react and node apps to an online server in a correct way for a long time. Your content, way of explaining and reasoning are well and easy to comprehend. Selected topics chosen well, they are practical fields widely seeked but rarely found enough info about them
@@astkh4381 not all environment variables need to come from your .env file, some can be set during the process initialisation, some can be set by the system itself, etc. One of those is process.env.NODE_ENV, which is set as PRODUCTION when built and run, vs run in npm run dev
There is really lack of content and tutorials on PERN stack. I really learned from every single video on your channel. Please keep up the great work. Hope you wont stop making these. Thanks :)
Dear Henry, I am so glad I stumbled upon your channel. I’ve added every single one of your videos to a playlist to watch, and I just subscribed. Thank you so much!!!
you are the real mvp, i started at your pern tutorial video like a month ago, now that i undertsand react and node better i'm trying to deploy it on heroku and connect it to my salesforce org, been hard stuck until i came back to youtube and found this video and i was really happy to find out it's the same channel, your work is appreciated and helpful ! thank you so very much
I would just like to thank you for the tutorial , it helped me a lot since there are not many PERN deployment tutorials, but yours is spot on ! Good explanations and everything :)
Hi Henry, Thank you so much for this video. It helped me really when I deployed an app Heroku for the first time. It was so amazing that I introduced it and talked about what I learned in a tech blog in Japanese. If it is unacceptable, please let me know. I will remove it immediately. Thank you.
As a junior dev doing fun projects on the side to continue improving my skills, this is great stuff! I've been looking to deploy on Heroku with this specific stack so this is perfect, as well as the JWT videos you have. Thank you!
I followed all your instructions. It works on my local server but when I deploy it I get, Failed to load resource: the server responded with a status of 503 (Service Unavailable) react_devtools_backend.js:4049 Unexpected token < in JSON at position 0
What is the best way to troubleshoot when my app is getting a 503 error? I am getting an unexpected token < in JSON at position 0 (my console is showing the error at const response = await fetch(`/todos`); it doesn't seem like the getTodos is working in production, even though it works locally. Any ideas on the best way to troubleshoot?
If anyone is using this with the previous JWT tutorial and you're getting a Unexpected JSON Token error, your JWT secret might not be getting pushed up to Heroku, what I did to fix this was to run this command: heroku config:set jwtSecret='mysecret!@' and it all started working properly.
Anyone know why when I have it deployed on Heroku, the fetching routes aren't working? I can't GET, POST, or PUT, although the form shows and should work. It works fine on localhost:5000
I found a solution among comments. I have configured in the db.js, "proConfig" object, it worked. const proConfig = { connectionString: process.env.DATABASE_URL, // Heroku addons ssl: { rejectUnauthorized: false, } }
Hello! I followed all your steps but I am facing a problem after heroku deployment. When I open my app on heroku, I get a "Not Found". Any fix for that? What could I have missed?
to clear the cache issue. what worked for me was I just shut down my front end server and back end server. I then started my back end server first followed by my front end. it all seems to be working. I did not have to re-install my package.json and dependencies.
Can you make a video showing what VSCODE Extensions you have installed? I've been watching your videos and there's some stuff happening when you hit save that my Extensions don't to. :/ I have to be very careful with some parenthesis and brackets.
This is a great tutorial but i have a problem after changing the proxy in package.json and deleting the package-lock.json and nodemodules i ran the command npm i and then i ran the server but it's showing the error:Failed to load resource: the server responded with a status of 401 (Unauthorized)
Is heroku good enough to handle the react side of an application? It seems this way works only with static applications, would someone be able to elaborate on what this means? is there any drawback of using heroku for both your front-end and back-end of a pern application? will there be scenarios where you must use another service for your front end?
I have a blank root page; the landing, routing and login all work but my root is empty; Did I miss something? Also, my JWT fails authorization on reloading the web page, only when run through the server with static file or deployed to production. Anyone come up with a solution?
It's an awesome project, but the node js version Changed a lot 'cause I had to use the specific version of this project on my current project, due to the index (server) never started or at least never catched the requests, that problem gave me a 503 code in heroku , to solve the problem just use the exact version of this project
Hey thank you so much for the tutorial, really helpful and well explained, but i'm still a little bit confused about the git in the local dev, when we do create-react-app, react already initialized a git repo on that folder(client), and when we were making the server (server folder), we also init a git repo, so my question is how does we interact with the code with git. example such as when making a change, do we need to do git command on both folders (git add . commit etc ) or just do it on the main one at the root of the project ? if so, what do we do to the git on the server and client folder ? sorry if i didn't explain it clearly
Rafly... great question. I stumbled upon your question at the perfect time since I struggled with this issue for days! If you have figured this out already disregard but I know it's a good possibility others are struggling with this as well... So... I don't think it was mentioned in this video(at least I don't remember it) but you are 100% correct that when you create react app it initializes a git repo, and this WILL cause conflicts because a git repository INSIDE of another git repository will be ignored by git. This git repository (the one buried inside of another one) is called a submodule. Like I said above submodules are always ignored by git so when you go to github you won't even see the contents of the submodule. Now here is the solution: when you have a submodule, like the client for instance all you have to do.... is delete the .git file. Now this is a hidden file so you will not see it with ls. Type ls -a and you will see the .git rear its ugly head. Delete this .git folder and you no longer have a submodule. At this point anytime you add to the staging area or git commit etc. It will include all folders on the project. It must have been done for the project on this video but was accidentally left out I suppose. What WAS done on the video is he took all of the contents of the server folder and put it into the root, this made one root level package.json and one root level.git for the entire project. I hope that helped because it drove me nuts lol.
Why is this impossible to do using Digital Ocean? I can't find a guide anywhere for a PERN stack deployment that gets into this video's level of detail
Hey Stoic, Im getting a weird issue with my heroku on startup. Is there a way we can correspond ? Its related to my router, its not grabbing anything from the backend.
thank you so much for this series!! I've been following along since the to-do list and it's my intro to full stack, so I was very pleased to be able to be able to learn so much! I'm running into a problem @ the 25:00 mark re:clearing cache: when I restart my React app the database entries don't load, although I triple checked and should have completed the previous steps (in client I deleted node_modules/package-lock.json & ran npm install, didn't comment out window.location). console shows this error: JSON.parse: unexpected character at line 1 column 1 of the JSON data (e index.js:1, getTodos ListTodo.js:27). I haven't touched the component code besides shortening the URL cuz of the proxy & changing quotes to backticks--any idea what might be wrong?
@@aileenwu1362 , so the reason the react app didn't work was that the proxy was not added to the package.json yet. I fixed the issue by adding the proxy (you can start at 22:12 to see how to it is done) and I clear the cache by first deleting the package-lock.json and node_modules, second installing the packages back in the react application, and third turning back on my react app. Hopefully, this helps your issue. Feel free to reply if you continue to face a problem.
@@TheQuackLearner yes! I had actually put the proxy into the root package.json and I understand now why it should be in the client one--thank you for your help!!
Great tutorial and code deployed OK. Just one question: when I enter a todo the list updates automatically but if I edit or delete a todo the list does not refresh itself - `window.location = "/"` is used after each operation, same as your code. I have to refresh to see the changes. Thanks.
Andrew Bateman so the problem is that a response is not being sent back by the server. The window.location can not be executed until a server does a res.send or res.json is returned. In your edit and delete server routes (index.js file) I notice you comment out the res.json. I fixed the issue by adding it back. Hopefully, that fixed your issue. Feel free to ask more questions if that didn't help your case. Anyway, I really like the documentation you set up!
For anyone who is getting a "Not Found" error in the console when they click on the Add button, I found that mine was due to SSL enforcement. I have added "ssl: { rejectUnauthorized: false }" in db.js within new Pool under the connectionString code. This has worked for me. So, it should be as below: const pool = new Pool({ connectionString: process.env.NODE_ENV === "production" ? proConfig : devConfig, ssl: { rejectUnauthorized: false } });
Hi, When the logs of my pern app says "no pg_hba.conf entry for host , user, database, SSL off". Could you please help me resolve the error? Thank you.
I think I just had the same error as you and I fixed it. The issue is that the connection to the database is missing a parameter. You must add a second parameter after connectionString, in the Pool({}) which is: ssl: { rejectUnauthorized: false } It is shown here in the docs. devcenter.heroku.com/articles/heroku-postgresql#connecting-in-node-js
@@timothywongej Honestly I have no clue! Security is something I know the least about. Under the section I linked, they say "Alternatively, you can omit the ssl configuration object if you specify the PGSSLMODE config var: heroku config:set PGSSLMODE=no-verify.". So that may be the only other option.
Is anybody else getting a timeout error when their app is deployed? My database is empty however whenever I try to add a new todo my request times out.
Bit late but was facing the same issue and cause for my issue was that Heroku requires SSL. So in your db.js file add the SSL key. const prodConfig = { connectionString: process.env.DATABASE_URL, //heroku addon ssl: { rejectUnauthorized: false, }, };
@@MrPogi-lf5gz ah I see , unfortunately Digital Ocean and Heroku have there own way of deploying there code. Digital Ocean is a IAAS , so it actually provides you your own server; therefore, this usually results to more configuration. Perhaps this article can give you a good introduction => codeburst.io/ricky-figures-it-out-devops-deployment-using-express-postgres-and-digital-ocean-15c2d961340e . Good question
MAKE SURE YOU ALSO ADD SSL TO YOUR CONFIG CODE!!!! if (process.env.NODE_ENV === 'production') { dbParams.connectionString = process.env.DATABASE_URL dbParams.ssl = {rejectUnauthorized: false} devcenter.heroku.com/articles/heroku-postgresql#connecting-in-node-js
Thanks man, it works like a charm, that is the I am looking for. I have configured in the db.js, "proConfig" object. const proConfig = { connectionString: process.env.DATABASE_URL, // Heroku addons ssl: { rejectUnauthorized: false, } }
You're a life saver! Been looking for a tutorial on deploying with the same stack. Thanks for the great explanations and context
Spent hours trying to figure out why it worked locally and not in Heroku. 503 Error in chrome, PostgreSQL error: no pg_hba.conf entry for host. Here is the fix....
Heroku needs this line when creating the pool:
ssl: {
rejectUnauthorized: false,
},
This will fix the Heroku problem but break the dev server. Create a new pool conditionally for production/dev like this:
const pool =
process.env.NODE_ENV === "production"
? new Pool({
connectionString: prodConfig,
ssl: {
rejectUnauthorized: false,
},
})
: new Pool({
connectionString: devConfig,
});
Boy do i love you, had the same thing, i was getting error 503
This is the code i used to ensure it worked on local server too
const pool =
process.env.NODE_ENV === "production"
? new Pool({
connectionString: proConfig,
ssl: {
rejectUnauthorized: false,
},
})
: new Pool({
connectionString: devConfig,
});
i love you man it worked........... i was trying to solve this errror from last 15 days
thank you. You just save me
You are amazing. Thank you so much, you saved my day for real I finished the whole tutorial and was super confused at why it would not work. Thank you so much
Another great tutorial, thank you Henry, suppose name from package author info :)! I have watched the PERN tutorial prior to this tutorial, it was also great. I was looking how to deploy my react and node apps to an online server in a correct way for a long time. Your content, way of explaining and reasoning are well and easy to comprehend. Selected topics chosen well, they are practical fields widely seeked but rarely found enough info about them
hi can you explain what is .env.NODE_ENV 16:18?We dont have it in our .env
@@astkh4381 not all environment variables need to come from your .env file, some can be set during the process initialisation, some can be set by the system itself, etc. One of those is process.env.NODE_ENV, which is set as PRODUCTION when built and run, vs run in npm run dev
There is really lack of content and tutorials on PERN stack. I really learned from every single video on your channel. Please keep up the great work. Hope you wont stop making these.
Thanks :)
Would love to see a forgot password video for the PERN app we have made. Thanks for the content!
Dear Henry,
I am so glad I stumbled upon your channel. I’ve added every single one of your videos to a playlist to watch, and I just subscribed.
Thank you so much!!!
From one Henry Li (Ly) to another, this was an amazing tutorial! Thank you!
you are the real mvp, i started at your pern tutorial video like a month ago, now that i undertsand react and node better i'm trying to deploy it on heroku and connect it to my salesforce org, been hard stuck until i came back to youtube and found this video and i was really happy to find out it's the same channel, your work is appreciated and helpful ! thank you so very much
hi can you explain what is .env.NODE_ENV 16:18?We dont have it in our .env
@@astkh4381 I'm at the same place. I think you have to add this at the Config Vars on the Heroku Settings. That's what I did.
I would just like to thank you for the tutorial , it helped me a lot since there are not many PERN deployment tutorials, but yours is spot on ! Good explanations and everything :)
Author plz come back. You did great lessons. I am russian and I don't understand english well, but your lessons are understood perfectly.
Если не знаешь английский, то это не твоё
@@mori7423 I don't agree )
@@bv9876 tak po angliiski ne pishut))))
My Site is up on Heroku as you instructed but database add delete or update is not working.Anything I have to look upon it? Thanks.
Henry - your tutorials are so helpful. Thank you so much! Learning so much from the way your breakdown your tutorials.
Hi Henry, Thank you so much for this video. It helped me really when I deployed an app Heroku for the first time. It was so amazing that I introduced it and talked about what I learned in a tech blog in Japanese. If it is unacceptable, please let me know. I will remove it immediately. Thank you.
As a junior dev doing fun projects on the side to continue improving my skills, this is great stuff! I've been looking to deploy on Heroku with this specific stack so this is perfect, as well as the JWT videos you have. Thank you!
I followed all your instructions. It works on my local server but when I deploy it I get, Failed to load resource: the server responded with a status of 503 (Service Unavailable)
react_devtools_backend.js:4049 Unexpected token < in JSON at position 0
Thank you for the tutorial!
I have a problem, when I try to open the app at Heroku I get error: Not found
nice tutorial ! PERN tutorials are so rare ! thanks you
Your videos have taught me so much man. Amazing stuff.
Thank you so much for this tutorial. It really helps me a lot!
What is the best way to troubleshoot when my app is getting a 503 error? I am getting an unexpected token < in JSON at position 0 (my console is showing the error at const response = await fetch(`/todos`); it doesn't seem like the getTodos is working in production, even though it works locally. Any ideas on the best way to troubleshoot?
in db.js:
const proConfig = {
connectionString: process.env.DATABASE_URL,
ssl: { /*
Thank you so much!!! best teacher ever..!!!!!!!!!
YOU ARE A LEGEND!
would be really awesome if you do a tutorial on React Routers :)
thank you for this tut btw
Thank you, Henry. You're great❤
If anyone is using this with the previous JWT tutorial and you're getting a Unexpected JSON Token error, your JWT secret might not be getting pushed up to Heroku, what I did to fix this was to run this command: heroku config:set jwtSecret='mysecret!@' and it all started working properly.
God bless you man !
Anyone know why when I have it deployed on Heroku, the fetching routes aren't working? I can't GET, POST, or PUT, although the form shows and should work. It works fine on localhost:5000
I have the same problem, seeking solutions
I found a solution among comments. I have configured in the db.js, "proConfig" object, it worked.
const proConfig = {
connectionString: process.env.DATABASE_URL, // Heroku addons
ssl: {
rejectUnauthorized: false,
}
}
Hello! I followed all your steps but I am facing a problem after heroku deployment. When I open my app on heroku, I get a "Not Found". Any fix for that? What could I have missed?
I have the same issue! Did you manage to fix it?
This helped me out a ton. Thank you!
thank you for the tutorial,
hi henry long time no see when do you back to your youtube channel we miss your video so much
Nice work man
Plz create full course of PERN stack. Or recommond me something plz. I am working on project and I would love to work with you.
i deployed the completed project to heroku, but it doesnt work. i get failed to load resource, server responded 503 and uncaught in promise "
to clear the cache issue. what worked for me was I just shut down my front end server and back end server. I then started my back end server first followed by my front end. it all seems to be working. I did not have to re-install my package.json and dependencies.
great tutorials Henry, watched all of them. Thanks for sharing!
I managed to deploy my app, but once i open the app link, it crashes and error 503 in console
@Omar, did you resolve this error? I ran into the same issue
@@pavloaleksyeyev5065 check ssl option when creating postgresql Client instance . This was the problem
@@oabouassy i am still getting this 503 error
@@oabouassy Can you be more specific?
@@petarp3938 I solved it bro thanks
FIX for error 503 (Service Unavailable) (ADD, UPDATE, DELETE not working) on db.js
const proConfig = {
connectionString: process.env.DATABASE_URL,
ssl: { rejectUnauthorized: false },
};
const pool = new Pool( proConfig );
you are a fucking legend
🙏
Can you make a video showing what VSCODE Extensions you have installed? I've been watching your videos and there's some stuff happening when you hit save that my Extensions don't to. :/ I have to be very careful with some parenthesis and brackets.
This is a great tutorial but i have a problem after changing the proxy in package.json and deleting the package-lock.json and nodemodules i ran the command npm i and then i ran the server but it's showing the error:Failed to load resource: the server responded with a status of 401 (Unauthorized)
Same here
Is heroku good enough to handle the react side of an application? It seems this way works only with static applications, would someone be able to elaborate on what this means? is there any drawback of using heroku for both your front-end and back-end of a pern application? will there be scenarios where you must use another service for your front end?
Thank you, man.
Can you also do a tutorial on Payment integration? And or image upload?
Thanks for the suggestion, I definitely look into those things!
@@TheQuackLearner I'm also looking forward to an image upload tutorial using PERN Stack
Sir I have a application on MySQL sequelize, React, Node and PhpMyAdmin..How to deploy the application on heroku for MySQL.
Fantastic 👏
Thanks for the wonderful tutorial dude..it would help me a lot...!
would this work fine if I used routes in my react app?
I have a blank root page; the landing, routing and login all work but my root is empty; Did I miss something? Also, my JWT fails authorization on reloading the web page, only when run through the server with static file or deployed to production. Anyone come up with a solution?
Thanks alot! Love
Thanks buddy!
Can you push to heroku with only a backend node server like what you shown in the video?
It's an awesome project, but the node js version Changed a lot 'cause I had to use the specific version of this project on my current project, due to the index (server) never started or at least never catched the requests, that problem gave me a 503 code in heroku , to solve the problem just use the exact version of this project
Please make another video about Express-Validator. I tried to use it with react and routes controller and it didn't work.
Hey thank you so much for the tutorial, really helpful and well explained, but i'm still a little bit confused about the git in the local dev, when we do create-react-app, react already initialized a git repo on that folder(client), and when we were making the server (server folder), we also init a git repo, so my question is how does we interact with the code with git. example such as when making a change, do we need to do git command on both folders (git add . commit etc ) or just do it on the main one at the root of the project ? if so, what do we do to the git on the server and client folder ? sorry if i didn't explain it clearly
Rafly... great question. I stumbled upon your question at the perfect time since I struggled with this issue for days! If you have figured this out already disregard but I know it's a good possibility others are struggling with this as well...
So... I don't think it was mentioned in this video(at least I don't remember it) but you are 100% correct that when you create react app it initializes a git repo, and this WILL cause conflicts because a git repository INSIDE of another git repository will be ignored by git. This git repository (the one buried inside of another one) is called a submodule. Like I said above submodules are always ignored by git so when you go to github you won't even see the contents of the submodule.
Now here is the solution: when you have a submodule, like the client for instance all you have to do.... is delete the .git file. Now this is a hidden file so you will not see it with ls. Type ls -a and you will see the .git rear its ugly head. Delete this .git folder and you no longer have a submodule. At this point anytime you add to the staging area or git commit etc. It will include all folders on the project. It must have been done for the project on this video but was accidentally left out I suppose. What WAS done on the video is he took all of the contents of the server folder and put it into the root, this made one root level package.json and one root level.git for the entire project. I hope that helped because it drove me nuts lol.
@@charleslamb5810 hey sorry for the late reply, thank you so much really clear things up for me
Hi! would this work if im using sequelize + postgres? Thanks for the tutorial!
YES IT DOES! thanks!
Why is this impossible to do using Digital Ocean? I can't find a guide anywhere for a PERN stack deployment that gets into this video's level of detail
czcams.com/video/xqHyMAlRtYw/video.html&t heres the video on how to deploy node.js backend with postgres to DigitalOcean in great detail
Hey Stoic, Im getting a weird issue with my heroku on startup. Is there a way we can correspond ? Its related to my router, its not grabbing anything from the backend.
I swear im not a bot I just hated the google plus era of having your first and last name
please do a video deploying on render now that heroku is no longer free
Hi, all my client folder just got replaced for a create-react-app new file
The local psql command could not be located. Can you let me know I tried changing the path
Bro are you still alive ? Why you stopped posting pern ?!
Can you show how to deploy using GitHub? How to do continuous deployment while developing?
thank you so much for this series!! I've been following along since the to-do list and it's my intro to full stack, so I was very pleased to be able to be able to learn so much!
I'm running into a problem @ the 25:00 mark re:clearing cache: when I restart my React app the database entries don't load, although I triple checked and should have completed the previous steps (in client I deleted node_modules/package-lock.json & ran npm install, didn't comment out window.location).
console shows this error: JSON.parse: unexpected character at line 1 column 1 of the JSON data (e index.js:1, getTodos ListTodo.js:27). I haven't touched the component code besides shortening the URL cuz of the proxy & changing quotes to backticks--any idea what might be wrong?
Hi ailleine! Is it possible you can pass me your code on GitHub so I can take a closer look at the problem?
@@TheQuackLearner yes!! here it is: github.com/wua3/pern-todo
@@aileenwu1362 , so the reason the react app didn't work was that the proxy was not added to the package.json yet. I fixed the issue by adding the proxy (you can start at 22:12 to see how to it is done) and I clear the cache by first deleting the package-lock.json and node_modules, second installing the packages back in the react application, and third turning back on my react app. Hopefully, this helps your issue. Feel free to reply if you continue to face a problem.
@@TheQuackLearner yes! I had actually put the proxy into the root package.json and I understand now why it should be in the client one--thank you for your help!!
Great tutorial and code deployed OK. Just one question: when I enter a todo the list updates automatically but if I edit or delete a todo the list does not refresh itself - `window.location = "/"` is used after each operation, same as your code. I have to refresh to see the changes. Thanks.
Hey Andrew, is it possible you can pass me your github code so I can take a closer look?
@@TheQuackLearner Hi, thanks.
github.com/AndrewJBateman/pern-stack-todo
Andrew Bateman so the problem is that a response is not being sent back by the server. The window.location can not be executed until a server does a res.send or res.json is returned. In your edit and delete server routes (index.js file) I notice you comment out the res.json. I fixed the issue by adding it back. Hopefully, that fixed your issue. Feel free to ask more questions if that didn't help your case. Anyway, I really like the documentation you set up!
@@TheQuackLearner Thanks. It works now. Amazing, I was only looking in the client file for the problem and it was on the server side. Thanks againl
anyone knows why i get empty page when I open localhost:5000?
error SSL: certificate verify failed
For anyone who is getting a "Not Found" error in the console when they click on the Add button, I found that mine was due to SSL enforcement.
I have added "ssl: { rejectUnauthorized: false }" in db.js within new Pool under the connectionString code. This has worked for me.
So, it should be as below:
const pool = new Pool({
connectionString:
process.env.NODE_ENV === "production" ? proConfig : devConfig,
ssl: { rejectUnauthorized: false }
});
Hi, When the logs of my pern app says "no pg_hba.conf entry for host , user, database, SSL off".
Could you please help me resolve the error?
Thank you.
I think I just had the same error as you and I fixed it.
The issue is that the connection to the database is missing a parameter.
You must add a second parameter after connectionString, in the Pool({}) which is:
ssl: {
rejectUnauthorized: false
}
It is shown here in the docs.
devcenter.heroku.com/articles/heroku-postgresql#connecting-in-node-js
@@CounterScroll hello! do you know if this has any security issues? I'm getting the same issue but not sure if this isthe only work around?
@@timothywongej Honestly I have no clue! Security is something I know the least about.
Under the section I linked, they say "Alternatively, you can omit the ssl configuration object if you specify the PGSSLMODE config var: heroku config:set PGSSLMODE=no-verify.". So that may be the only other option.
Is anybody else getting a timeout error when their app is deployed? My database is empty however whenever I try to add a new todo my request times out.
Bit late but was facing the same issue and cause for my issue was that Heroku requires SSL. So in your db.js file add the SSL key. const prodConfig = {
connectionString: process.env.DATABASE_URL, //heroku addon
ssl: {
rejectUnauthorized: false,
},
};
@@leonseled you are the MVP
devcenter.heroku.com/articles/heroku-postgresql#connecting-in-node-js
had to use this documentation. Changed the const to client. I don't know why pool didn't work.
const { Client } = require('pg');
require("dotenv").config(); //using ENV variables in .env
let client;
const devConfig = `postgresql://${process.env.PG_USER}:${process.env.PG_PASSWORD}@${process.env.PG_HOST}:${process.env.PG_PORT}/${process.env.PG_DATABASE}`;
if (process.env.NODE_ENV === "production"){
client = new Client({
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false
}
});
} else{
client = devConfig;
}
module.exports = client;
is Procfile neccesary ? or not ?
Make one on aws considering Heroku removed its free tier
King
Can you do this on DO?
Hi brigz, what does DO stand for?
@@TheQuackLearner Digital Ocean.
@@MrPogi-lf5gz ah I see , unfortunately Digital Ocean and Heroku have there own way of deploying there code. Digital Ocean is a IAAS , so it actually provides you your own server; therefore, this usually results to more configuration. Perhaps this article can give you a good introduction => codeburst.io/ricky-figures-it-out-devops-deployment-using-express-postgres-and-digital-ocean-15c2d961340e . Good question
@@TheQuackLearner thanks. Awesome channel by the way. Hope you keep adding contents into it!
MAKE SURE YOU ALSO ADD SSL TO YOUR CONFIG CODE!!!!
if (process.env.NODE_ENV === 'production') {
dbParams.connectionString = process.env.DATABASE_URL
dbParams.ssl = {rejectUnauthorized: false}
devcenter.heroku.com/articles/heroku-postgresql#connecting-in-node-js
Thanks man, it works like a charm, that is the I am looking for. I have configured in the db.js, "proConfig" object.
const proConfig = {
connectionString: process.env.DATABASE_URL, // Heroku addons
ssl: {
rejectUnauthorized: false,
}
}
@The Stoic Programmer ur duscord server?
You don't have to pull out your entire server folder.....
Hi Henry! I'm here from your fCC video. I have a proposal which you might find relevant. What's your email address? I cannot find it anywhere.
@Dayton Junior THIS IS A SCAM
are you alive ??
thank you , but how your app understand is this porudction or not 16:18.And what is .env.NODE_ENV
I added authentication and I can't seem to register or login. Throws an error