Skip to content

Serving a SPA and APIs #867

Answered by davidpdrsn
Stefan99353 asked this question in Q&A
Mar 17, 2022 · 3 comments · 11 replies
Discussion options

You must be logged in to vote

Try this

let app = Router::new()
    .route("/api/auth", get(|| async { "API: /auth" }))
    .fallback(
        get_service(ServeDir::new("./dist")).handle_error(|_| async move {
            (StatusCode::INTERNAL_SERVER_ERROR, "internal server error")
        }),
    );

Replies: 3 comments 11 replies

Comment options

You must be logged in to vote
6 replies
@Stefan99353
Comment options

@davidpdrsn
Comment options

@davidpdrsn
Comment options

@Stefan99353
Comment options

@davidpdrsn
Comment options

Answer selected by davidpdrsn
Comment options

You must be logged in to vote
5 replies
@tombh
Comment options

@davidpdrsn
Comment options

@tombh
Comment options

@davidpdrsn
Comment options

@tombh
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants