Heroku Routes to backend not working in development mode - node.js

I made a simple todo application with React,Node and Mongodb. The application works fine while run on the dev server. When I deploy it, however, it appears as though the app can't hit the todo API routes. Any help would be appreciated.
this is my github repo link(https://github.com/Ashish5911/notebook-backend/)

Would suggest you to identify the presence of errors in Heroku log for further analysis.
You can open the Heroku log by pressing the View logs button as seen in the below pop-up menu:

.env is in your .gitignore file, which is what is not pushed to Heroku. If you remove .env from your .gitignore, that may help. I faced the same issue before.

Related

deploying nodejs and mongoDB to azure

I have a nodejs/express application and an atlas mongoDB set up. I can get the data from the database to my app if it is running on local host. When I try and deploy the app as a web app through Azure, it does not work; I click the button to get/display the data but nothing happens. What is causing this issue and how do I fix it?
I figured out what was wrong. My repository did not include a web.config file at all. Having never worked with web applications or Node before, I did not know this was needed. Once I added the file and put the proper path in, the code began working as intended. I can update this post with actual code if someone wants it.

Cannot set property 'locale' of undefined, not working in replit but at my pc

I get this error on replit but on my pc the bot works well, but i want to host my bot free 24/7.
This is the error
This is my i18n configure in my code
If there is an other website where i can paste my code and host it with express it would also help me.
thx
Repl.it is just not reading the sub-prototype 'locale' from your targetObject you should just try switching hosts :)
Check out Heroku. It's free and you can get 550-1,000 hours of runtime for 0$. Probably the best feature of this hoster is the GitHub integration, so you don't have to upload your bot's code manually, but can connect your GitHub to a project and choose from which branch you want the code.
You can also set it to automatically update your project on Heroku when you push to the selected branch.
Important note: If you host your bot on Heroku, for example, config.json cannot be used. Variables like the bot-token etc. must be set on heroku. The best thing to do is to watch this tutorial, everything is explained there

Azure Service Editor config changes are not applicated

I have a problem with my QnA Bot App. I made some changes to basic responses (No answer found, Hello and Goodbye) in Azure Service Editor. I have also changed a default HTML webpage. Changes made in a HTML website were made instantly, but the config files with new welcome responses were not.
I am sure that I once watched a tutorial that provided information that after you change some stuff in configs files you need to commit them using Kudo Console. I tried restarting the app but it did not work.
I am beginner. Does anyone remember what is the command?
I tried searching through my whole browser history but I still cannot find it.
I used command deploy and it worked.

Node server routes all timing out

No idea what happened... It was working and then it wasnt.
I am currently building a web app and decided to take some time off from the product side and build a landing page.
For some reason, I decided to build the landing page on a separate Github branch. So I checked out to a new branch, deleted everything, and started working on the landing page.
I soon realized this is a terrible idea and created a new repo to store my landing page.
I checked back into my master branch and spun my Node server up but for some reason now, everything is timing out. I opened Postman and tried hitting some of my endpoints but after like 3 minutes of loading, it tells me that it could not get any response and that there was an error connecting to localhost:3001/api/posts
In my terminal, all I see is this when I hit the route:
GET /api/posts - - ms - -
This has never happened to me before and I am completely clueless on WTH happened.
I tried deleting my local stuff and re-cloning the repo and installing my dependencies but to no avail...
Would love to know if someone has an idea on what's going on.
Check first is this isn't because of another process already listening on that port (but using resources which were deleted or not properly updated)
Closing applications or even rebooting can help you asserting if the issue is permanent or just linked to your current session.
The OP Syn points out in the comments the ~/.env file missing
.env files allow you to put your environment variables inside a file.
You just create a new file called .env in your project and slap your variables in there on different lines.
To read these values, there are a couple of options, but the easiest is to use the dotenv package from npm.
npm install dotenv --save
Note: it is generally not versioned, as it includes potentially sensitive date.

How to get standard out from a Node.js application in Azure?

We have a Node.js application with a pretty big codebase that we're trying to deploy to an Azure Web Site. My problem is that when I deploy the app and try to access it, I just get a message saying "The page cannot be displayed because an internal server error has occurred".
According to http://azure.microsoft.com/en-us/documentation/articles/web-sites-nodejs-debug/ I should be able to configure some settings and have my standard out be logged to a file - well, it's not working. in /LogFiles I can see /git, /html, and /DetailedErrors, but none of these folders contain the stdout logs.
I have deployed the app using Visual Studio. I created a blank Azure project, and manually added all the folders and files I need. I also created an iisnode.yml file that contains the following config:
loggingEnabled: true
devErrorsEnabled: true
logDirectory: ./logs
debugHeaderEnabled: true
The last two lines I added later, the first ones are from the tutorial. I also have a web.config file, the contents of which I haven't really touched.
I've attempted to configure the settings that are available in the Web Sites UI, but I haven't really been able to make any headway. I think currently they are pretty much default.
I'm sorry that I can't provide you with more information. I'm really kind of banging my head against the wall here, since all the tutorials I've found basically state that if I do this and that, everything should work. The problem is, it doesn't. Sad face.
Edit: I should probably add that my server.js is in a folder called /NodeServer. It's not in the root as Azure seems to presume.
Edit2: I deployed a Hello World example and got it to work, but when I try to move the server.js file from the root I can't get it to work anymore.
I've added a tag to the web.config, so that the structure is basically
configuration
location path="NodeServer"
system.webServer
I've also edited my package.json so that it says
"main":"NodeServer/server.js",
"scripts":{
"start":"cd NodeServer && node server.js"
}
If the app is started successfully, you should be able to find the stdout at
D:\home\LogFiles\Application
in Azure Websites, without configuring anything.
But here it looks like an error related to incorrect/missing web.config. The node app may not get launched. You can try:
Publishing your app using git to Azure Websites.
Or if you are familiar with IIS and iisnode, make sure your app works locally with IIS and iisnode. See http://tomasz.janczuk.org/2011/08/hosting-nodejs-applications-in-iis-on.html
Or try publishing an "hello world" node.js app to Azure Websites, take the generated web.config and modify it for your app.
Edit: When you change the location of server.js, you have to change web.config too. The change in web.config is not correct. And package.json is only used as hints to generate web.config during git deployment. To get your "hello world" to work, you can either
In your web.config, replace all "server.js" with "NodeServer/server.js".
Or deploy the modified app using git. Make sure it does not contain the wrong web.config.
Then you can try to get your larger app to work.

Resources