How to deploy a angular app that isn't scaffolded with yeoman - angularjs

I have a angular app, just a angular app so no nodejs or other backend is involved. I have a separate backend setup with an API. My angular app communicates to the backend with the API.
Now when I want to put my angular app online, how do I do this? If I just put the html files online I get all kinds of errors (I already have a separate question for this matter, which is unresolved). Deploying to heroku doesn't work because it isn't a nodejs app.
So how is this accomplished?

You can use an apache server or nginx to serve static content on a remote server. Personnaly I use Nginx, it doesn't require a lot of configuration (almost no configuration) to works.

Related

Microservices architecture tutorial for springboot and react in production

My project contains two apps. Backend – springboot and a frontend - React.
I am using the spring-boot app only as a rest API to fetch data from the database. The React app frontend will call the API. Up until now, we were using only one environment (Windows) so production build was one jar that actually contains both apps and a tomcat. That was quite simple so by adding a proxy in the package.json file to point to the backend and some maven(frontend-maven-plugin) plugin the building process is simple.
Now we need to change the system architecture so each app will be hosts on a different windows machine.
I was trying to use express to host the react app but I am struggling with the proxy setup for the backend (spring) app from the express server. All the tutorials that I found actually using the express server as the backend API but I need the express server only for hosting the production build.
Is there a good tutorial that shows how to set up this type of architecture in production env.
Thank you

React & Laravel: split API and Frontend?

As I have learned a lot for now about React and Laravel, I can of course create a laravel app using
laravel new MyApp
and set the preset to react with
php artisan preset react
Now I can build a nice app with frontend and API.
But is this best practice? I'm wondering if it wouldn't be better to install a react app i.e. with create-react-app and seperate it from laravel as I don't need the whole view stuff in laravel.
Building with React CLI create-react-app
You can host your website with static hosting server which is far more cheaper for more traffic scenario.
Although separate php server his required to host api part with laravel but, these api can be used in mobile apps. You may host on single server with a subdomain.
SEO will be a headache. You will need a separate nodejs function to inject the seo tags or any other way.
As you frontend and backend is isolated, your system will be a bit safer from backend/admin panel vulnerabilities. You just need to secure all your apis.
Building within laravel php artisan preset react
Easy SEO part with server side rendering possible using laravel.
Single server, single domain easy to maintain.

Can I deploy Angular JS to AWS S3 bucket and expect routing working there or do I have to use EC2? And what is “static Angular js page”?

I’m new and learning how to deploy to AWS.
I made angular JS website and tried to deploy it at localhost with node.js npm/bower. It’s worked. I tried to deploy it at MS Azure: deployed it from Github and it’s worked as well well (I did not do anything in setting and did not install node.js, but maybe Azure did it automatically?).
The last, I tried to upload it at AWS S3 bucket as a static webpage with allowing public access. It wasn’t work property: I can only see my index.html content but no routing content: so basically almost nothing of my webpage.
I saw a similar question (“How do I set up an AngularJS app using AWS?”) where a person was wonder about options to upload an AngularJS to S3 bucket or EC2. The answer says that one can use S3 at AWS if it's angular js static webpage. The person of that question went for EC2 option. If I’ll go for S3 option: I’m confuse: what is “static Angular js page” actually? will routing work at S3 or I must use EC2 with node.js?
First, you should really do a simple search and read the differences between static and dynamic webpages.
If you are using some sort of server-side technology like NodeJS, Java, Python, Ruby, etc. to generate the HTML for your web pages whenever a request is made then you have a dynamic webpage and you would need to host that on EC2.
If your webpage is simply HTML, CSS and JavaScript files, and the raw content of those files does not changes with each request then you have a static webpage, which can be hosted on S3. The advantages of a static webpage is that it is much cheaper to host, and when hosted somewhere like S3 it can handle massive amounts of traffic without any extra configuration or management on your part.
In your case I believe you are only using NodeJS as a script that you run once to generate/output your static AngularJS content. If that's the case then you have a static website. If however you are also using NodeJS as a server to handle HTTP requests dynamically then you have a dynamic website.
AngularJS is a client-side technology. AngularJS runs entirely in the browser. As such you should be able to host your AngularJS application on S3.
Since AngularJS routing works entirely on the browser side, it shouldn't matter where the page is hosted. You should expect it to work if the page is hosted in S3, since it actually runs in the browser, not the server.
What is “static Angular js page” actually?
Static AngularJS refers to the frontend content such as HTML, JS, CSS, Images & etc. You should be able to implement routing for static content from S3.
Will routing work at S3 or I must use EC2 with Node.js?
If you can separate the AngularJS App Static Content and Backend Code (e.g NodeJS Server Logic with Database access & etc.) then you can host, the AngularJS App in S3 and use EC2 for backend. This can get challenging to setup. To route both to the Frontend in S3 and to the NodeJS backend, in addition you can use AWS CloudFront.
However, since you are new to AWS, it would be better to use either AWS Elastic Beanstalk or EC2 with NodeJS i n the beginning for deployment.

Deployment of Angular JS project having rest calls

I am new to Angular Js. Following in my scenario.
I have static website.(i.e. pure html pages) deployed on godaddy.
I am developing Angular Js applications.
Angular is calling rest api developed in java.
I have taken aws vpc and deploying rest api on two Wildfly 9.0 server and apache 2.4 as load balancer.
Now I have confusion where to deploy Angular js app.
Whether I should deploy it on godaddy along with my static site(Merge both of them into one).
Whether I should deploy my static site and angular js app (again merge) on apache in aws vpc.
Whether I should deploy angular js app on wildfly server.
Need your suggestion which scenario will be better.
Since you have a static site, you can put it into a S3 bucket and not have to worry about the hassle of a server. This way you don't have to worry about the size of the server or load balancing.
http://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html

Should I deploy my SPA files to the same "website" as my web service?

I'm building an SPA in angular with a web api backend. If I deploy my SPA files to a separate IIS website from my web service then I have to deal with cross domain requests. But if I put everything in one site, then there's no problem. Is there anything wrong with deploying the two to the same site?
No, there is not nothing wrong with deploy all in the same server. If you concern is performance remember optimize your js and css files. Also you can use CDN services to serve your static files.

Resources