Issues with Multipage Access in Cloudfront

I’m deploying Streamlit using AWS behind Cloudfront and eventually on Fargate using an ALB. The app works fine when I start at the homepage, but I can’t directly access any of the multipage pages. I can navigate to them from the homepage, but not directly via a link. When hitting them directly via the link I received a 502 Bad Gateway error which I believe is due to the below changes in URI

I notice that, when locally deployed, the websocket when going to the homepage or directly to a separate page is simply localhost/_stcore/stream. In my deployed environment the websocket request includes the page name as in {domain}/{some_page}/_stcore_stream. Could this be some cloudfront proxy behavior that I can fix?

I’ve tried redirecting and directly changing the request URI to remove the {some_page} part leaving the expected {domain}/_stcore/stream. Directly changing the request fixes the 502 error but I’m redirected to the homepage, not the actual linked page. I’ve also tried configuring websockets for Cloudfront but that doesn’t appear to be the issue as the site works fine when arriving first at the homepage.

It appears similar to the issue mentioned in this post but I’m running streamlit 1.28

Thanks for any help! I’m mainly curious if there are any resources to understand how the websockets for _stcore/stream work so I can better understand what kind of routing I need to do.

Have you read our forum posting guide?

I have the exact same issue… have you figured this out?

Looks like it should invoke ${protocol}://${host}:${port}/${fullPath} from the code snippet. Don’t know if this is an issue from cloudfront or streamlit.

I didn’t find a solution, but I instead just used query parameters to mark pages.