how to move from localhost to server? Nodejs - node.js

I have a nodejs application working on my laptop. I can view it in the browser by going to http://localhost:3030/.
I have installed nodejs,npm and all the packages I need on a server and copied all the files on the server as well.
When I start the application using node app it seems to be running fine. But It can not find any of the public static content, client-side javascript, client-side css etc. I see 404 errors in my browser console.
All nodejs tutorials seems to stop at localhost.. how to deploy an app on a server?

Related

localhost refused to connect when I ran parcel and next.js's web server

I developed a simple web site using HTML and TypeScript and ran the web server using Parcel.
npx parcel index.html
Now it looks okay in the terminal.
But I can connect on the browser.
I was able to connect localhost:3000 when I worked on Next.js app before but now I can't even connect to this app's server as well as Parcel's server localhost:1234 .
I guess there happens common tricky issues related to localhost.
Please let me know what I should do to figure out this.
I've already followed this link but nothing was figured out...
Also I tried on not only Google Chrome but also Mozilla Firefox and IE but there were same issues..

Angular Universal not starting on Phusion Passenger Node Server

I have an Angular Universal Project, deployed on a node server. I built it then deployed the content of dist folder to my server. Browser folder is reached, so I get the index.html page. But API calls return timeout, and when I refresh a page with any other route, it also returns a timeout.
I think that my express server is not started.
Anyone has an idea?

ERR_CONNECTION_REFUSED on EC2 public DNS caused by HTTPS

I'm developing a web app using Next.js that is, in the end, served by a custom Express.js server. I'm trying to deploy this app on EC2 and access it but I'm getting ERR_CONNECTION_REFUSED errors.
I'm accessing the app over HTTP using the public DNS of my instance (http://ec2-PUBLIC_IPV4_ADDRESS.compute-1.amazonaws.com/) which works fine, the index.html then needs to load other files (e.g.: .js or .css files), but tried to load them over HTTPS (https://ec2-PUBLIC_IPV4_ADDRESS.compute-1.amazonaws.com/style.css). In the network tab of the developer tool of Chrome, I get one request that is succesful and other assets that fail with net::ERR_CONNECTION_REFUSED.
I was wondering if there is a config either on my EC2 instance, on my Express server or even on Next.js that needs to be modified to make sure that the connection is not upgraded to HTTPS.
I would prefer to find a solution that doesn't involve setting up a domain for early testing purposes.
Thanks in advance.

NodeJS Express app not working as expected - showing it's content instead of executing

I've created a node webapp with express-generator, this app works great on localhost.
But as soon as i move my app to the server and surf the domain, it shows the content of the app.js file instead of executing it, i've tried to reproduce this issue on localhost without success.
I've also checked the configuration of the web server, looks good so far.
If i run the app on localhost, the app.js file gets executed without any problems, but on the webserver the file content is shown only and nothing executes.
This only happens with the app.js file, any other file of the app works fine, views are rendered and routes are working.
I'm grateful for any help!
Some additional information:
OS: Windows Server 2016 Datecenter
Node 12
Node app deployed via Plesk Obsidian
This is solved, it looks like this is a problem with iisnode since the app works as it should when it runs as a service

I've deployed a nodejs api to Heroku and a React app to my personal site and I'm getting cors errors but going to the api url directly gets response?

I've written a NodeJs app with an express server that runs fine on heroku. From my local machine, with the proxy set in package.json of my React app, I can interact with the API. From the browser I can also interact with it. However the deployed React app on my site can't get the resources. Heroku is picking up the GET requests by the way.
I'm not very well versed in Dev ops, networking, deployment so I'm wondering where in the system I'm running into the problem and where I should look to fix the problem.
Edit:
I've added the cors npm package. I can make fetch requests from the browser. But my site can't...
Def sounds like a cross origin error! The browser is masking error details from react for security purposes. Try adding npm install cors & then add it as middleware - you can view the npm package here

Resources