Angular Universal not starting on Phusion Passenger Node Server - node.js

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?

Related

website not opening in first time shared link in browser angular 8 and nginx

bhaskarhindi.com id an angualr8 front end and Nginx server hosted in AWS instance using nodejs Redis API call to fetch data.
But after deploying and using hash the first time in the browser it is not opening showing 404 error.
But after a hard refresh or multiple time click it's opeing.
Any solution i have tried index.html aot and hashed build but not working.
404 is shown by the server itself, when it tries to find the route you have passed in the URL (as the server doesn't have access to that route, but Angular has).
You need to make sure that the server redirects all the 404 requests to the index.html of the Angular application. Only then Angular can pick up and show the pages accordingly.
Read through this: https://angular.io/guide/deployment#server-configuration for more information.

Create a part of `Express` Web application as an `Angular` app

In the past few weeks I've setup a small website using Node and Express. The routing is done via express and the website consists of the root route as (http://localhost:3000/) and some sub routes like /contact or /login and so on.
Now I want to create an angular app as a part of that express app. So I want to create that angular app running on the sub-route (localhost:3000/dashboard) of the whole website.
How can that be done and solved?
The routes of the angular app should be managed either by the Express app or the Angular app?
Hope anyone can help me.

How to make Express server use React routes?

Previous I had my server running on port 5000 and my react app running on port 3000. I would access it through port 3000 and it would do API calls to port 5000.
I have now added this so that the server will serve the react build:
But the issue I have now, is that all my routers on the app don't work. When I go to http://localhost:5000/ my homepage shows up fine, but if I go to http://localhost:5000/1 or whatever, it says it cannot get those pages.
What's meant to happen is that my router here kicks in and loads the correct components:
I'm new to the MERN stack and this is my first time trying to have the server send the build files. What should I search to solve this? How can I fix this? My guess is that I have to rewrite the app.get to send the correct files, but my build only has one file so IDK what to do. I'd rather not have to rewrite my whole server.
You have no .htaccess and no nginx and any other URL redirector here. You can handle it with express:
app.get('*', (req,res) =>{
res.sendFile(path.join(__dirname+'../poll/build/index.html'));
});
After your express routes.
React route do routing on browser. but in here routing is done in server side.
you should always return index.html in react application no mater which url you request.
if you want to work with both server side routing and browser routing, you may use HashRouting in react
https://reacttraining.com/react-router/web/api/HashRouter

How to hide third party api fetch requests in react with nginx

I setting up React app and Node js for api server, also I deployed it on Docker.
How to intercept React api requests with nginx, and send them to node js server, while the backend should not be accessible from the browser
Please, give some links or github repositories.
Can you specify what does backend should not be accessible from the browser? back end is not accessible from the browser, if you mean hide request uris there are no way to do it, only option is to encode uris and uglify code

how to move from localhost to server? Nodejs

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?

Resources