Hello i'm trying to develop a restful api using nodejs and express, and i also want to create a client-side application using angularjs. As explained in AngularJS oficial website:
"The angular-phonecat project is configured with a simple static web server for hosting the application during development. Start the web server by running:
npm start
This will create a local webserver that is listening to port 8000 on your local machine. You can now browse to the application at:
http://localhost:8000/app/index.html"
So i should run client side app in node web server. but my restful api also run in my node web server. How should i set up node js to be able to run both instances of nodejs at the same time and be able to conect to my restful api from my angularjs application
If your app is structured like angular-phonecat, open your package.json file and find where the npm start command is configured (hint: "scripts" > "start") and change the port that http-server is using.
i.e. "http-server -a 0.0.0.0 -p new_port_number"
Related
I have built a react app using a truffle box that uses create-react app. I can get the app running on my local host but I can't see it on my VPS when I go to the IP address of my VPS and I run exactly the same commands and I get the same output in the terminal. I go in to my client dir and run npm start. I have tried to make a build and run the build through an http server in the client dir and the root folder of the VPS.
I run
serve -s build
All I can see is the index of the build in the browser when I try and serve the build through a webserver. When I run npm start on my localhost I can view my app but it doesn't work on my VPS. Please help me I've been struggling with this for days and its the last part of my project.
You need a webserver in any case.
When you do a local development, you do use webpack dev server (which is inside of create react app).
For the production, you need to make a production build and serve it for example by nginx. Here some details how to create production build with CRA https://create-react-app.dev/docs/production-build
On your screenshot, you don't see your site, because there is no entry point in your folder. By default it should be index.html
I start my React app using:
npm start
This starts the app on localhost:3000
I would like to have it start with a domain instead of localhost. When testing locally, I have a local domain (example mydomain.com) set to IP address 127.0.0.1. This allows me to use the actual domain in code when making requests to the backend. Without this, my code would need to support both localhost and my domain and swap them out in production.
npm start is only a command to run your react app in development mode.. for faster build and publish functionalities..
So for production, you will be using npm build to get a production build for the same. This won;t be automatically deplyed or hosted on your localhost:3000.
So production deployment you will have to host your compiled build files using IIS or some hosting application. There you can configure your preferred DNS, whcihever domain name you would want to use.
You can customise the url for deployment for development.
In your .env.development add this line
HOST='mydomain.com'
If you want to deploy at https, add this line also in same file
HTTPS=true
How do I run an angularjs front-end web app on codenvy? The app uses angular-route.js for routing between pages. I have tried using the preview function, but that one seems to not work due to the routing...
One way is to use a workspace which has a web server like apache httpd installed. For how to do that see How do you install an apache server (httpd) on codenvy?
Another thing to try is to unbound the app from localhost, i.e. use host as 0.0.0.0
I've created an Angular 1.6.x application using Visual Studio Code, with bower'ed dependencies. The Angular app talks to a separate ASP.NET MVC REST/API application for data (eventually with adal-angular).
Locally, I'm using http-server to run the Angular app successfully using npm start:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "start http://localhost:8080/app/index.html && http-server -a localhost -p 8080"
},
While I've been able to successfully get the Angular source code to my defined App Services on the Azure (verified using the Web App's console option) using the Continuous Delivery mechanism, it's not entirely obvious how the application will start, specifically:
How does Azure know how to do a "npm start"? Where do I instruct this to happen, if it's not automatic?
How would I instruct my application to use process.env.PORT, instead of port 8080?
Assuming I get past this initial issue, are there guidelines for http-server usage on Azure? Or are there other recommended ways to serve Angular SPAs?
FWIW, I note that the trying to run 'npm start' from the Azure console results in an 'ELIFECYCLE' error.
As you deploy your app to Azure WebApp, Azure will use IIS to host your app and only ports 80 and 443 are public-facing. So you don't need any other HTTP server to server your web application on Azure.
You can clarify what issue you ran into when you visited your website, so we can help to figure out what's wrong there.
The Azure Web App model hosts node.js/Angular apps within IIS, therefore a configured web.config file is required. The magic glue between IIS and node is the iisnode module: https://github.com/tjanczuk/iisnode that allows hosting of node.js applications within IIS.
The web.config file can direct IIS to start the app's app.js (or server.js) file, which would include a reference to process.env.PORT.
A good overall guide for deploying node apps is: https://blogs.msdn.microsoft.com/laurelle/2015/12/01/how-to-deploy-a-node-js-site-into-azure-web-app-to-create-a-website/.
The best guideline and documentation I could find on setting up a web.config is here: https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
Hi all i have completed my webapplication using angularjs, In local iam using tomact server in eclipse and it is working fine, Now i want to deploy my application to webserver what is the process to do it.
For ex : my local url is : http://localhost:8080/Hms/#/
i want to the url as http://www.hms.com
Please help me i am new in angularjs
If your angular web application depends on Tomcat server;
If you haven't own server for web hosting which has http ://www.hms.com, your hosting provider should provide Tomcat feature.
If you have own server for web hosting which has http ://www.hms.com, just copy paste your all files in your project folder e.g. $TOMCAT_PATH/webapps/your-project-root/. And redirect http ://www.hms.com to Tomcat port (default is 8080)
If you are using only AngularJs, it shouldn't depend on Tomcat. You can use angular boilerplate https://github.com/adilkaraoz/ngbp. Github link provides information in details. With ngbp, just copy build folder inside into the your web hosting and at the and you have http //www.hms.com url which include your web files.
You can deploy this project same as how you are deploying other web applications in tomcat. Hope you build a war file and deploy them.
Angularjs is a javascript framework as Jquery. For server it's javascript, which will be served back to the client as other js files.
Please refer how deployments are done tomcat. Just fyr, https://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html
Thanks.