R
Railwaymanuai

How can I access to the SLL certificate file? My app config requires it

I have a bun app, that seems to require the full path to a certificate. Where could I get that ? Thanks
P
Percy43d ago
Project ID: N/A
M
manuai43d ago
Essentially I need to provide a path here
No description
B
Brody43d ago
railway handles that for you, do not try to start an https server
M
manuai43d ago
Thanks Brody, so what am I supposed to return from the server file ?
B
Brody43d ago
just dont do any tls stuff, start a plain old http server
M
manuai43d ago
I have a werid issue where all HTTPS call get redirected to HTTP
B
Brody43d ago
can you give me a link to where i can see that behavior?
M
manuai43d ago
B
Brody43d ago
thats just a 404 though
M
manuai43d ago
Can't seem to reproduce from the browser, but the Bun app, thinks that request.url is http so whenever url.origin is used, it output http instead of https
B
Brody43d ago
the bun app that you have deployed to railway thinks that the incoming requests are http?
M
manuai43d ago
correct
B
Brody43d ago
well because they are your app would need to trust the proxy headers, X-Forwarded-For and X-Forwarded-Proto X-Forwarded-Proto would always be set to https
M
manuai43d ago
Any idea on how to do that ?
B
Brody43d ago
im sure bun has docs for that
M
manuai43d ago
looking it up
M
manuai43d ago
Does that look like the right place to do that ?
No description
B
Brody43d ago
no?
M
manuai43d ago
Sorry I am lost. Is X-Forwarded-Proto: https a header I should add somewhere ?
B
Brody43d ago
do some research on trusting proxy headers doesnt need to be in the context of bun, just in general so you get an understanding of what it means
M
manuai43d ago
God I hate devops 😄 Just for the quick tip, is that a header I should send from the client ?
B
Brody43d ago
always more stuff to learn eh? no, railway's proxy sets the header, your bun app needs to read from it so that it knows the requests where made from https
B
Brody43d ago
here's a blurb from some express middleware for trusting the proxy headers https://expressjs.com/en/guide/behind-proxies.html
No description
M
manuai43d ago
Alright, will do some (more) research. Thanks a lot Brody !
M
manuai43d ago
Does that look like the right track ? https://hono.dev/middleware/builtin/secure-headers
Secure Headers Middleware - Hono
Ultrafast web framework for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
B
Brody43d ago
not at all why does it even matter in your case that requests come in as http? is this posing some real problem?
M
manuai43d ago
Yes it does, a whole lot of headach burnt the whole day on this
B
Brody43d ago
why does it matter if the incoming requests are http or https
M
manuai43d ago
As I understand it's the server that has to acknowlege that header right ? Cause the client then send HTTP, which get redirected to HTTPS, which doesn't work for POST request
B
Brody43d ago
why is their any redirection? the client should make https calls, not http calls
M
manuai43d ago
Railway does that no ?
B
Brody43d ago
not unless you are doing something wrong
M
manuai43d ago
http://castaway-production.up.railway.app/ That gets redirected no ? I am just spining up a container that works fine locally, no fancy config at all
B
Brody43d ago
why are you making requests with http
M
manuai43d ago
Because the library I am using, relies on Hono request data to create URLs for the client. If hono says that's HTTP, then all my links are HTTP If you know farcaster, this is a setup for farcaster frames
B
Brody43d ago
okay now thats a good explanation right so we are back to trusting the proxy headers you figure out how to trust the proxy headers, then hono will see the request as https and make the correct URLs
M
manuai43d ago
But that's gotta be on Hono side right, if they don't have support for this then I am stucked ?
B
Brody43d ago
you can always write your own middleware that does this
M
manuai43d ago
So the idea is, request comes in, check the header, then somehow force Hono to acknowledge this as legitimate https
B
Brody43d ago
basically yeah, you are able to set values in the request object before hono comes into play, you read the protocol from the header and set the protocol in the request object in a middleware, then when hono comes into play it will read the protocol and create the correct URL
M
manuai43d ago
That makes. I got the first part down. I get the IP this way, so now I have to check thats its a valid domain (will worry about that later) then update the request, correct?
No description
B
Brody43d ago
where do domains come into play here also that middleware purely prints the IP, it doesn't actually set the IP in the request object
M
manuai43d ago
Yes, that's the missing bit I am tryiing to figure that out Never mind the domain (sorry I am being thick here) I haven't touched a container in years, I was hoping devops got easier since then To be fair, Railway is awesome
B
Brody43d ago
haha this is just normal running your app behind a proxy stuff, I'm surprised there isn't a package to do this for you express has a dead simple way of doing it that's literally one line
M
manuai43d ago
yea, no info whatsoever on the subject, it's crazy Everything is read only on the request object 😦
M
manuai43d ago
Ok looks like that did it
No description
B
Brody43d ago
okay now just read the value from the header and fallback to http if there is no header
M
manuai43d ago
got it, if x-forwarded-for is in there, the use https Thanks a tone Brody, saved me hours for sure
B
Brody43d ago
if the header is there, then use the headers value
M
manuai43d ago
Right, this makes sense
B
Brody43d ago
if there's no header then don't do anything with it as the default value of http will be correct yo thank you for the trains
Want results from more Discord servers?
Add your server
More Posts
Urgent: Prisma cannot find the required `libssl`My site just went down. I am having the same problem as this https://discord.com/channels/7135033453Can i temporarily remove my MySQL Database without deleting it completely?I want to perform this because I am running out of credits and I am also not using the DataBase in rusage based pricingPlease help me understand how a project on railway with 0 usage (no calls to the server or DB) for aHelp with setup of laravel cmds on project deploymentHello everyone so im hosting a laravel rest api but i cant seem to access the terminal and run cmds Postgres Database private url, is it faster and how to use it?I have a Django rest framework setup with postgress db and it seems the connection is slow. I noticumami deployment fails since migration of railwayHi there, I hope you can help me. I am not too well with backend (database, docker, etc) programminIs Go 1.22 supported yet?I remember getting deployment issues when trying to support Go 1.22 in the past. I assume it's a matIs Go 1.22 supported yet?I remember getting deployment issues when trying to support Go 1.22 in the past. I assume it's a matmy plan is 5$My plan is 5$ why I pay now 51$. ?? Please deactivate my account I don't need this server in which eFile too large on Gitlab CI/CDHi, i'm trying to add a CI/CD to my project but the deploy part always fail saying ```File too largeCan't find my repo on railwayIt was recently migrated to be a organization repo that I have admin access to. How do I deploy baseDeploying to Railway from Gitlab CI/CDwhere to get project token from project serviceApp Crashed - Resource temporarily unavailableMy backend nodejs app crashed multiple times today. could not find the root cause. this has not hapDatabase server does not connectGood afternoon, I have already made all the connections with the postgreSQL database server but whenDeploy logs stopped appearing after a manual redeployHi, I have a project running several services. Deploy logs for one of the services randomly stopped ENOTFOUND redis.railway.internalFirst time using railway. I'm on team plan which says it supports private networking. I have a simplError: libuuid.so.1: cannot open shared object file: No such file or directoryGetting this error with puppeteer on Railway. ``` node:internal/modules/cjs/loader:1239 return pro"Error: connection already closed."I keep getting this error message when I attempt to update a user in my PostgreSQL database. I do noUnable to update Variables in App. (First Update after Migration)Hey Guys, my App tries to connect to the old containers of my postgres and redis. I checked the variImage Storagehello everyone, can I use Postgresql to store the images which my users upload in django-project?