a year ago
I have a bun app, that seems to require the full path to a certificate. Where could I get that ?
Thanks
0 Replies
a year ago
n/a
a year ago
railway handles that for you, do not try to start an https server
a year ago
just dont do any tls stuff, start a plain old http server
a year ago
can you give me a link to where i can see that behavior?
There it is https://castaway-production.up.railway.app
a year ago
thats just a 404 though
Can't seem to reproduce from the browser, but the Bun app, thinks that request.url is http
a year ago
the bun app that you have deployed to railway thinks that the incoming requests are http?
a year ago
well because they are
a year ago
your app would need to trust the proxy headers, X-Forwarded-For
and X-Forwarded-Proto
a year ago
X-Forwarded-Proto
would always be set to https
a year ago
im sure bun has docs for that
a year ago
no?
Sorry I am lost. Is X-Forwarded-Proto: https a header I should add somewhere ?
a year ago
do some research on trusting proxy headers
a year ago
doesnt need to be in the context of bun, just in general so you get an understanding of what it means
a year ago
always more stuff to learn eh?
a year ago
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
a year ago
here's a blurb from some express middleware for trusting the proxy headers
Does that look like the right track ? https://hono.dev/middleware/builtin/secure-headers
a year ago
not at all
a year ago
why does it even matter in your case that requests come in as http? is this posing some real problem?
a year ago
why does it matter if the incoming requests are http or https
Cause the client then send HTTP, which get redirected to HTTPS, which doesn't work for POST request
a year ago
why is their any redirection?
a year ago
the client should make https calls, not http calls
a year ago
not unless you are doing something wrong
That gets redirected no ? I am just spining up a container that works fine locally, no fancy config at all
a year ago
why are you making requests with http
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
a year ago
okay now thats a good explanation
a year ago
right so we are back to trusting the proxy headers
a year ago
you figure out how to trust the proxy headers, then hono will see the request as https and make the correct URLs
But that's gotta be on Hono side right, if they don't have support for this then I am stucked ?
a year ago
you can always write your own middleware that does this
So the idea is, request comes in, check the header, then somehow force Hono to acknowledge this as legitimate https
a year 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
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?
a year ago
where do domains come into play here
a year ago
also that middleware purely prints the IP, it doesn't actually set the IP in the request object
I haven't touched a container in years, I was hoping devops got easier since then
a year 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
a year ago
express has a dead simple way of doing it that's literally one line
a year ago
okay now just read the value from the header and fallback to http if there is no header
a year ago
if the header is there, then use the headers value
a year ago
if there's no header then don't do anything with it as the default value of http will be correct
a year ago
yo thank you for the trains