Change localhost to domain (mongodb, nodejs) - node.js

There is a "template" sort of thing for a shopping like website and I want to make it work on a domain, instead of localhost. The source code is here: https://github.com/jakblak/BestDressed
I already have the domain, and my domain is set up with my VPS so it will run off of that. But again, I would like it to work on the domain instead of localhost. I would also like no port, e.g: localhost:9000
Thanks in advance and sorry if this was a hassle.

Basically you have to install and run this node application on your server and make appropriate configuration changes. After a quick look, it seems you can find them under server/config/environment/.
The exact way depends largely on your specific setup.

Related

Can I host/deploy a standalone MERN app as part of another website?

(I'm fairly sure this question reflects a lack of familiarity with the tools available, but my searches didn't turn up much.)
Let's say I have a MERN project that works entirely on its own, let's call it my-app. When I run the server locally, it works exactly as intended - I browse to localhost:3000 and I get what I want. What I'm looking for is a way to host that project as part of another website (that I own), such that I can navigate to example.com/my-app and be served the exact same content as when I browse to localhost:3000 while hosting locally.
The actual use case here is that the project is open source, so ideally the project would be totally agnostic and unopinionated about where it is hosted. Using a subdomain (my-app.example.com) may be easier, but I would like to avoid it if possible. I would also like to avoid simply hosting the project somewhere else and redirecting to it - I know there are ways to redirect without changing the URL, but ideally this would work with something like git submodule such that the main website and the app project can all be hosted from the same server instance.
If I am understanding your question correctly, yes, you could create a standalone MERN app and host it on another site. One method of doing so would be an iframe. You can just place the iframe within a page on the new site by setting the src to the location of the MERN app like so: src="http://example-mern-app.com.

How to deploy a React + Express app on a local network?

This is my first post here, let me know if I do it wrong. I would like to start by mentioning that I'm kind of a beginner developer. I've had a bunch of classes, but it's also my first time working on something of my own, from beginning to end (emphasis on "end").
I'm working on a relatively simple app, for user management (CRUD, with different levels of authorizations) and shop management. I was given the choice of the tools, framework, language, etc, to use, with the only constraints that 1/ the main device to use it will be a tablet most of the times 2/ nothing should be hosted online. I wanted to get more familiar with Javascript so I went with creating a React app (front) with Express Nodejs (back) and a MySQL database I access via Sequelize.
Development is going fine (for the most part thanks to many great posts here on SO), but I just got hit by the reality that I have never tried to build the app and see if it runs the way I intend. And I do not know how to do it. I should have researched that earlier.
So far, in development I always tested everything on PC and phone by running npm start (front end) and node server.js (back end), and the client runs in a browser (when using a phone I access the IP adress and port, like 192.168.x.x:3000). Backend listens to the 8080 port no prob, access to the MySQL database works as intended thanks to Sequelize. Frontend listens to port 3000 to display the user interface on the browser, and React makes it easy to develop features in front, and quickly troubleshoot them. Everything works fine, and as expected, anyone in the same network (and with a web browser) can access and use the app that way.
This is the behavior I want to replicate with a production build : having a computer host the build, and run the "server" so that the app is available to any device in the local network. So I guess I need to somehow make my build in a way to make it possible to turn on and off the "server" at will, maybe via a .exe ? Or turn it on at the same time as the computer ?
I know I should have researched that earlier and not doing so was a mistake. All I know is I'll have to use npm run build, to get the build folder, but I don't know what to do from there. Could you help me figure it out ? Among many things I'm not sure of, is whether or not the host computer (not mine) needs to have node.js installed ? Does it also have to have MySQL installed ? Do I make a single build that incorporates the backend and the frontend, or do I build both separately ? If so, how ?
Let me know if you need to see part of the code. Thanks in advance and have a great day.
EDIT : App was created using create react app
There are options to deploy on cloud like Cloud Servers. But I think you're looking for hosting the application on the local machine. You need to create a service, bundle the application and serve whenever you want.
Following link might be helpful
https://www.section.io/engineering-education/compile-your-nodejs-application-into-a-exe-file/

How can I publish a node-express website under an existing server?

I have a web-server with cPanel, but I didn't find the method to make the website properly work. I made an aldomain, updloaded the project, but it doesn't recognise the base css, nodejs server etc... Tha main question is how to run my own server.js file on the server(?!), and how to make it looks like on localhost? Is it possible? If it's not, how can I publish it? I know that I shouldn't send this message here, because it doesn't contain any code, but nobody tells me where can I ask theese kind of questions. Can you tell me this too, please?
Bad news is cPanel doesn't support Node.js. Prof link
Good news is here you can make question without any code.

Node.js and ColdFusion on the same server?

I have question about how to set Node.js server application. On my server I have ColdFusion application server. I can test my code through browser url. I would like the same for Node.js. Node is already installed on my server but the only way to run the code is through cmd command window. First question is what I need in order for both to run on the same server? I still need my ColdFusion. Second question is about Nodes.js and can I set up server application with ISS or I need something else? Also do I have to specify what extension on my files will point to ColdFusion and other to Node. For example .cfm extension is for ColdFusion and .js is for the Node. If anyone knows anything about this or where I can find more information please let me know. I never experienced something similar and this is something completely new for me.
I know this is an old post but I figure I'd provide an answer for those souls who are looking around.
If working with Apache 2.4.x.
In a test environment this would not be to much of an issue as Node and Coldfusion operate on different ports.
If your looking to create a production site than I would say that building a virtual host with proxy to the node site and Coldfusion would be another method.
If you are using the Coldfusion connector to Apache and loading node, than still loading the proxy for the node part would be fine, just make sure you are pointing to the correct port for your node.
Things to remember:
You may have to alter internal Firewall rules.
Comment your hosts files so you don't accidentally alter the wrong file.
Both can exist within the same platform.

Where to put node.js code in cPanel

I am entirely new to backend development so this might be a ridiculously easy and straightforward question, but I'm really not sure. I am trying to learn node.js for backend development, and all of the tutorials I have seen so far show how node can be used to run JavaScript from the terminal and create a server on local host. While this is a neat thing to do, I am stuck there and having difficulty understanding where to put my node.js code on cPanel and how to use it effectively along with the rest of my html/css/js code; all the examples I have seen are very isolated and don't have much interaction with these other files.
Again, I don't have any backend experience, so it would not be very helpful to explain this concept relative to another server-side language like Python, Ruby, or PHP, as I really have no idea where I would put any of the code for any of that stuff either or how it fits into the bigger picture. If the answer could maybe touch on how to integrate Python or PHP as well and general patterns for backend development---the easy stuff everyone assumes but no one explains---it would be much appreciated.
It doesn't matter where you put it. However you probably want to keep it in the folder of the username which is using it. I created a folder called app/ in my users folder and put all my crap in there. Then you simply set it up to listen on a port approved by your host.
You can use a .htaccess file in your public_html folder to redirect to the correct port number.
Your node.js will handle routing. So to go to certain css/html files you will have to set that up in your node.js code.

Resources