Redirection In FastAPI to a particular endpoint of frontend - redirect

I am new to FastAPI and have a FastAPI backend running on port 8000 and a Nextjs frontend running on port 3000. In the backend I want to send a redirection response so that the frontend goes to http://localhost:3000/test, but when I send response as return RedirectResponse(url='/test'), the page goes to http://localhost:8000/test (backend port) instead of going to http://localhost:3000/test (frontend port). Do I have to write the full redirection with port number also as return RedirectResponse(url='http://localhost:3000/test')?

Related

GWT with http loadbalancer gives invalid SID value

I have 2 openfire servers and an elastic loadbalancer over them and built a gwt application that using http bind at port 7070
when connecting directly to one server it works good but when it connects to the loadbalancer on port 7070 it’s not working and output an error with 404 invalid SID value
Note:
When the load balancer is working at tcp mode it works fine but when its http mode it doesn’t work and i need to make a sticky session for it
That's because once BOSH session is established on one machine then it's tied to this machine. Without enabling sticky session on the ELB subsequent requests from the client can be routed to the second server, on which there is no BOSH session that maches the request, which in turn results in invalid SID (because SID doesn't exist on the other machine).
Alternative solution would be (if the machines would also expose public IP) to return "host" information in the BOSH response therefore client could use that information and then make subsequent requests to correct machine. But if that's not possible, they ou have to use "sticky session".

Haproxy backend unique server request

I have the following set haproxy receives tcp/ssl connection does the ssl removal and should forward the tcp request to a single backend server(i can only have a single server). Its working however i am having a performance issue because the haproxy maintains a the connection to the final server i cannot have the full performance of that server. it is possible to configure the haproxy so that every server connection is unique?

how to find process.env.PORT port number in heroku?

I need to post json data from a IOT device to the server api endpoint. But it requires the port number. How can i find a port number for process.env.PORT in heroku?
You don't need to know that port number.
Within the process, Heroku requires you to bind that process. But their router will expose ports 80 and 443 and route requests properly to the process(es) running your app.
In order words: you bind to $PORT in a single process. Heroku's router binds to 80 and 443, and routes to one of many processes (or dynos).
All you have to do is make a request to your-app-name.herokuapp.com.

Socket IO using Cloudflare gives 404s for /socket.io/?EIO=3&transport=polling&t=M8UDUNL

I am working on a node.js site that uses socket.io on ports 8443 and port 443. The site works locally as well as using namecheap for dns records pointing to the production server. I recently set the nameservers to Cloudflare and added the same A record there that I was using at namecheap. Now everything works except for the socket.io to port 443. Requests using port 443 that are not using socket.io are working fine.
I am getting this error:
GET https://<domain>/socket.io/?EIO=3&transport=polling&t=M8UDaUZ 404 ()
Port 8443 socket.io requests are getting 200 responses, and include an sid:
https://<domain>:8443/socket.io/?EIO=3&transport=polling&t=M8UDUTx&sid=cuq1LLdLLVSj2F4FAAAN
I am not sure if the sid missing on the port 443 requests indicates the problem. When I asked cloudflare support about it, their response was 404 means to check the path.
The only thing that has changed is the DNS so I don't think this can be a path problem or a code problem with the site. It seems like it has to be something Cloudflare is doing differently than namecheap for dns or socket.io connections.
I don't see any other errors. Does anyone know what the problem could be or how to fix it for Cloudflare?
Have you managed to solve the issue?
I was dealing with the same issue (or looked the same) and what helped me was setting sockets.io listen to HTTP server.
Server code:
var http = require('http');
var server = https.createServer(app).listen(80, function() {
console.log('Express HTTP server listening');
});
var io = require('socket.io').listen(server);
var secureServer = https.createServer(httpsOptions, app);
console.log('Express HTTPS server listening');
});
Client uses wss:// (so transport is secure).
Also I have CloudFlare option "proxy all HTTP to HTTPS" enabled.

Is it possible to expose Twitter's Finatra admin pages (port 9990) on the main service port?

We are working on a service using Twitter's Finatra. The main web services are exposed in port 8080 (using override def defaultFinatraHttpPort = ":8080"). Finatra exposes Finagle's Http Admin interface automatically on port 9000. Is it possible to instruct it to expose the /admin/* endpoints on the main application port (i.e. 8080)?
I've tried overwriting the 'adminPort' var, however Finatra will try to create another Http listener on that port, which will fail because there is one already created. What I'm trying to do is to link the admin controllers to the main Http listener, so that everything is accessible from one single http port.