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
Related
Let's say I have a C# app that sends HTTPS requests to a webserver.
https://www.webserver.com/checkid=anything
And the web server checks the Id of the request and returns a string response such as Not Active back to the app.
This response will lock some features inside the app.
Is there any way I can redirect that request to another server that I controll and send fake responses such as Active back to my client app through node js proxy or something?
Note: I dont have access to the app source.
OK i found another better solution, I just used Fiddler Everywhere to change the server response to a custom one.
I am using nodeJS and expressJS for backend and ReactJS for frontend of my application. Everything works fine when run locally on my computer. However, I recently have tried to deploy the app using Heroku. The app successfully launches at the given link from Heroku but then whenever I try to sign in/sign up I'm always thrown an error from the backend. The error is as follows when I am using Safari and Google Chrome respectively:
I have already enabled cors on my expressJS server, what is the likely cause of the issue?
It looks like your ReactJS code has the url http://localhost:5000/ hard coded in it somewhere. If your same Heroku instance serves the ReactJS and provides your API endpoints, then you should consider using
/api/users/signup
for the URL of your API endpoint instead of
http://localhost:5000/api/users/signup
This wrong URL shows up as an access control issue because browsers block external pages served by https to use localhost APIs. Because cybercreeps.
I am using node.js and express to render some pages like home pages and some other SEO routes.
For a specific route I want to serve a react SPA which I host on a CDN.
on that page I load the main.js from the cdn, but it is trying to load the rest of the assets from the node server, not the CDN.
One solution is to serve the SPA from node, but I know serving assets from node on production is not the best practice.
So how do I render some routes locally with node, and proxy another to a SPA application?
Do I need a third server for reverse proxy?
Thank you!
Hi I have two process
Django and MYSQL
node/express and mongo db.
1.
How can I configure this two process to point to different url
like. Django point to api.abc.com/v1 and node point to api.abc.com/v2 ?
2.
all my user login is inside Django and MYSQL with OAuth. I can authenticate user in Django.
But how can authenticate user in nodejs app with the token send by Django REST OAuth ?
Thanks.
You can do it in few ways but the most convenient method would be to use a reverse proxy like nginx.
Configuring the reverse proxy for your Node app and doing exactly the same for your Django app will let you easily have the routes that you require, on the same domain name and port number just in a different path.
Another option would be to proxy requests either from the Node app to the Django app or the other way around, but that would require changing your applications instead of just putting a proxy in front of them.
Here are some questions with onfo on how to configure reverse proxies for Node using nginx, Apache and even Microsoft IIS:
NGINX Reverse Proxy Causes 502 Errors On Some Pages
reverse proxy using ngix and ssl implementation on express failed
SSL With node / IIS
Adding chat through websocket, to an existing PHP web app
Where do I put my Node JS app so it is accessible via the main website?
How to run nodejs server over 443 ensuring nginx doesnt stop working
Configuring HTTPS for Express and Nginx
Scenario A
You create a url in django ^v2/.*$ and then make a request from django view to node.js process. this way django can handle user auth and permissions and node can be standalone and not know anything about user auth. If you need user data (id or something) you can inject it in the request as a header or a cookie.
Scenario B
You dig into django REST OAuth implementation, find where tokens are stored in db, and on each request you take the oauth token from the header/cookie and compare it to the one in DB. You would have to setup nginx as a reverse proxy and route all traffic that goes on url /v1/.*$ to django app, and all traffic that goes to /v2/.*/ to node app.
Either options are doable but I would suggest Scenario A. It's easier, quicker and far less error prone.
I am creating a web application where I want to display hundreds of images. I am using NodeJS with the Express Framework.
How do I send images from server to client?
Edit: If I place all images in the public directory, are they automatically send to the browser if the page is rendered or are GET requests generated in time if those images are needed?
Are you required to use express? Usually, static files are better served using a proper web server (like nginx or apache) along with your node/express application or some kind of cdn. In the client you could configure how your images are requested to avoid loading all of them at the beginning, either only downloading on demand or doing non-blocking requests