poem icon indicating copy to clipboard operation
poem copied to clipboard

Regex with EmbeddedFilesEndpoint

Open skrcka opened this issue 4 months ago • 0 comments

I am nesting a React Application inside Poem app and need to serve it under all endpoints except for some

Working example:

#[derive(RustEmbed)]
#[folder = "frontend/dist"]
pub struct Frontend;

Server::new(TcpListener::bind(ip))
        .run(
            Route::new()
                .nest("/api/v1", api_service)
                .nest("/api/v1/docs", ui)
                .nest("/api/v1/openapi.json", specs)
                .at("/*", EmbeddedFilesEndpoint::<Frontend>::new())
                .with(AddData::new(pool.clone()))
                .with(JwtMiddleware)
                .with(Cors::new()),
        )
        .await

React app is correctly served when "/" url is accessed. However if I try to open /some_route I get 404 even tho the React application should know the route.

What I need is something like: .at("/<.+>/*", EmbeddedFilesEndpoint::<Frontend>::new())

Basically I need to serve the frontend app under all endpoints expect for my custom ones that are used as backend, is that possible?

skrcka avatar Oct 13 '24 18:10 skrcka