Accessing localhost for iframe

isaac-flath
PRO

a year ago

I am using a new framework (FastHTML) that is an htmx framework. I have deployed it, but it's not able to access the extra services that should be running on the server. I've tried searching and found things that may be related, but it all went a bit over my head.

Here's the issue (right iframe): https://fasthtml.gallery/chat_bubble

What I am trying to do is run a starlette ASGI server on localhost using uvicorn, and then use that as the src for an iframe. I will be launching many of these, based on the number of small example widgets I have add to the page.

The code base of the app is here where the server is launched and referenced: https://github.com/Isaac-Flath/FastHTML-Gallery/blob/main/main.py#L92

Are there resources or directions someone can point me in to how I should be doing this?

Solved

6 Replies

a year ago

localhost is an address that's only available locally, when you run code anywhere else than on your own computer you will have to point the iframe at a real public domain.


Status changed to Awaiting User Response railway[bot] 11 months ago


isaac-flath
PRO

a year ago

Oh, so we cannot run any local services on the server the app is deployed on?

Is the recommendation for any additional services that need to be run, to do separate railway deployments then?


Status changed to Awaiting Railway Response railway[bot] 11 months ago


a year ago

That is correct, if you are running a different kind of app you would want to run it in another Railway service.


Status changed to Awaiting User Response railway[bot] 11 months ago


isaac-flath
PRO

a year ago

Ah bummer. I guess I need to get an EC2 server or something then. Thanks anyways!


Status changed to Awaiting Railway Response railway[bot] 11 months ago


a year ago

This still would not work on EC2.

You need to point the iframe to a public domain when running the site on the cloud, localhost is not a public domain.

https://en.wikipedia.org/wiki/Localhost


Status changed to Awaiting User Response railway[bot] 11 months ago


isaac-flath
PRO

a year ago

I got it all working on 1 server with a few slight tweaks - Thanks anyways for your help!


Status changed to Awaiting Railway Response railway[bot] 11 months ago


Status changed to Solved brody 11 months ago