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

2 years ago

I have a bun app, that seems to require the full path to a certificate. Where could I get that ?

Thanks

75 Replies

2 years ago

n/a


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

Essentially I need to provide a path here

1215393138676596700


2 years ago

railway handles that for you, do not try to start an https server


Anonymous
TRIALOP

2 years ago

Thanks Brody, so what am I supposed to return from the server file ?


2 years ago

just dont do any tls stuff, start a plain old http server


Anonymous
TRIALOP

2 years ago

I have a werid issue where all HTTPS call get redirected to HTTP


2 years ago

can you give me a link to where i can see that behavior?


Anonymous
TRIALOP

2 years ago


2 years ago

thats just a 404 though



Anonymous
TRIALOP

2 years ago

Can't seem to reproduce from the browser, but the Bun app, thinks that request.url is http


Anonymous
TRIALOP

2 years ago

so whenever url.origin is used, it output http instead of https


2 years ago

the bun app that you have deployed to railway thinks that the incoming requests are http?


Anonymous
TRIALOP

2 years ago

correct


2 years ago

well because they are


2 years ago

your app would need to trust the proxy headers, X-Forwarded-For and X-Forwarded-Proto


2 years ago

X-Forwarded-Proto would always be set to https


Anonymous
TRIALOP

2 years ago

Any idea on how to do that ?


2 years ago

im sure bun has docs for that


Anonymous
TRIALOP

2 years ago

looking it up


Anonymous
TRIALOP

2 years ago

Does that look like the right place to do that ?

1215407740038422500


2 years ago

no?


Anonymous
TRIALOP

2 years ago

Sorry I am lost. Is X-Forwarded-Proto: https a header I should add somewhere ?


2 years ago

do some research on trusting proxy headers


2 years ago

doesnt need to be in the context of bun, just in general so you get an understanding of what it means


Anonymous
TRIALOP

2 years ago

God I hate devops 😄


Anonymous
TRIALOP

2 years ago

Just for the quick tip, is that a header I should send from the client ?


2 years ago

always more stuff to learn eh?


2 years 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


2 years ago

here's a blurb from some express middleware for trusting the proxy headers

1215409360172482600


Anonymous
TRIALOP

2 years ago

Alright, will do some (more) research. Thanks a lot Brody !


Anonymous
TRIALOP

2 years ago

Does that look like the right track ? https://hono.dev/middleware/builtin/secure-headers


2 years ago

not at all


2 years ago

why does it even matter in your case that requests come in as http? is this posing some real problem?


Anonymous
TRIALOP

2 years ago

Yes it does, a whole lot of headach


Anonymous
TRIALOP

2 years ago

burnt the whole day on this


2 years ago

why does it matter if the incoming requests are http or https


Anonymous
TRIALOP

2 years ago

As I understand it's the server that has to acknowlege that header right ?


Anonymous
TRIALOP

2 years ago

Cause the client then send HTTP, which get redirected to HTTPS, which doesn't work for POST request


2 years ago

why is their any redirection?


2 years ago

the client should make https calls, not http calls


Anonymous
TRIALOP

2 years ago

Railway does that no ?


2 years ago

not unless you are doing something wrong



Anonymous
TRIALOP

2 years ago

That gets redirected no ? I am just spining up a container that works fine locally, no fancy config at all


2 years ago

why are you making requests with http


Anonymous
TRIALOP

2 years 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


Anonymous
TRIALOP

2 years ago

If you know farcaster, this is a setup for farcaster frames


2 years ago

okay now thats a good explanation


2 years ago

right so we are back to trusting the proxy headers


2 years ago

you figure out how to trust the proxy headers, then hono will see the request as https and make the correct URLs


Anonymous
TRIALOP

2 years ago

But that's gotta be on Hono side right, if they don't have support for this then I am stucked ?


2 years ago

you can always write your own middleware that does this


Anonymous
TRIALOP

2 years ago

So the idea is, request comes in, check the header, then somehow force Hono to acknowledge this as legitimate https


2 years 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


Anonymous
TRIALOP

2 years 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?

1215423679765414000


2 years ago

where do domains come into play here


2 years ago

also that middleware purely prints the IP, it doesn't actually set the IP in the request object


Anonymous
TRIALOP

2 years ago

Yes, that's the missing bit I am tryiing to figure that out


Anonymous
TRIALOP

2 years ago

Never mind the domain (sorry I am being thick here)


Anonymous
TRIALOP

2 years ago

I haven't touched a container in years, I was hoping devops got easier since then


Anonymous
TRIALOP

2 years ago

To be fair, Railway is awesome


2 years 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


2 years ago

express has a dead simple way of doing it that's literally one line


Anonymous
TRIALOP

2 years ago

yea, no info whatsoever on the subject, it's crazy


Anonymous
TRIALOP

2 years ago

Everything is read only on the request object 😦


Anonymous
TRIALOP

2 years ago

Ok looks like that did it

1215427214972158000


2 years ago

okay now just read the value from the header and fallback to http if there is no header


Anonymous
TRIALOP

2 years ago

got it, if x-forwarded-for is in there, the use https


Anonymous
TRIALOP

2 years ago

Thanks a tone Brody, saved me hours for sure


2 years ago

if the header is there, then use the headers value


Anonymous
TRIALOP

2 years ago

Right, this makes sense


2 years ago

if there's no header then don't do anything with it as the default value of http will be correct


2 years ago

yo thank you for the trains


Loading...