fix: Remove redirect on index

This commit is contained in:
Ginger 2026-03-18 12:31:27 -04:00
parent 6451671f66
commit 0cc188f62c
No known key found for this signature in database
3 changed files with 14 additions and 12 deletions

View file

@ -1,10 +1,6 @@
use std::sync::Arc; use std::sync::Arc;
use axum::{ use axum::{Router, response::IntoResponse};
Router,
response::{IntoResponse, Redirect},
routing::get,
};
use conduwuit::Error; use conduwuit::Error;
use conduwuit_service::{Services, state, state::Guard}; use conduwuit_service::{Services, state, state::Guard};
use http::{StatusCode, Uri}; use http::{StatusCode, Uri};
@ -14,8 +10,7 @@ pub(crate) fn build(services: &Arc<Services>) -> (Router, Guard) {
let router = Router::<state::State>::new(); let router = Router::<state::State>::new();
let (state, guard) = state::create(services.clone()); let (state, guard) = state::create(services.clone());
let router = conduwuit_api::router::build(router, &services.server) let router = conduwuit_api::router::build(router, &services.server)
.nest("/_continuwuity/", conduwuit_web::build()) .merge(conduwuit_web::build())
.route("/", get(async || Redirect::permanent("/_continuwuity/")))
.fallback(not_found) .fallback(not_found)
.with_state(state); .with_state(state);
@ -23,5 +18,5 @@ pub(crate) fn build(services: &Arc<Services>) -> (Router, Guard) {
} }
async fn not_found(_uri: Uri) -> impl IntoResponse { async fn not_found(_uri: Uri) -> impl IntoResponse {
Error::Request(ErrorKind::Unrecognized, "Not Found".into(), StatusCode::NOT_FOUND) Error::Request(ErrorKind::Unrecognized, "not found :(".into(), StatusCode::NOT_FOUND)
} }

View file

@ -76,11 +76,14 @@ pub fn build() -> Router<state::State> {
#[allow(clippy::wildcard_imports)] #[allow(clippy::wildcard_imports)]
use pages::*; use pages::*;
Router::new() let sub_router = Router::new()
.merge(index::build())
.merge(resources::build()) .merge(resources::build())
.merge(password_reset::build()) .merge(password_reset::build())
.fallback(async || WebError::NotFound) .fallback(async || WebError::NotFound);
Router::new()
.merge(index::build())
.nest("/_continuwuity/", sub_router)
.layer(SetResponseHeaderLayer::if_not_present( .layer(SetResponseHeaderLayer::if_not_present(
header::CONTENT_SECURITY_POLICY, header::CONTENT_SECURITY_POLICY,
HeaderValue::from_static("default-src 'self'; img-src 'self' data:;"), HeaderValue::from_static("default-src 'self'; img-src 'self' data:;"),

View file

@ -3,7 +3,11 @@ use axum::{Router, extract::State, response::IntoResponse, routing::get};
use crate::{WebError, template}; use crate::{WebError, template};
pub(crate) fn build() -> Router<crate::State> { Router::new().route("/", get(index_handler)) } pub(crate) fn build() -> Router<crate::State> {
Router::new()
.route("/", get(index_handler))
.route("/_continuwuity/", get(index_handler))
}
async fn index_handler( async fn index_handler(
State(services): State<crate::State>, State(services): State<crate::State>,