From: Dessalines Date: Thu, 12 Dec 2019 05:28:33 +0000 (-0800) Subject: Moving front end routes from nginx to actix X-Git-Url: http://these/git/%22https:/image.com/%24%7BappleTouchIcon%7D?a=commitdiff_plain;h=665dca80d00c3947a4838bbd468cfdcb9241ace5;p=lemmy.git Moving front end routes from nginx to actix - Fixes #363 --- diff --git a/ansible/templates/nginx.conf b/ansible/templates/nginx.conf index c8afcf4b..a484594e 100644 --- a/ansible/templates/nginx.conf +++ b/ansible/templates/nginx.conf @@ -50,7 +50,6 @@ server { client_max_body_size 50M; location / { - rewrite (\/(user|(?\d+\.\d+\.\d+)\. $ip.0; + ~(?P[^:]+:[^:]+): $ip::; + 127.0.0.1 $remote_addr; + ::1 $remote_addr; + default 0.0.0.0; + } + log_format main '$remote_addr_anon - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" "$http_user_agent"'; + access_log /dev/stdout main; } diff --git a/server/src/main.rs b/server/src/main.rs index cdcd7a65..98ce8e3f 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -198,20 +198,51 @@ fn main() { HttpServer::new(move || { App::new() .data(server.clone()) + // Front end routes + .service(actix_files::Files::new("/static", front_end_dir())) + .route("/", web::get().to(index)) + .route( + "/home/type/{type}/sort/{sort}/page/{page}", + web::get().to(index), + ) + .route("/login", web::get().to(index)) + .route("/create_post", web::get().to(index)) + .route("/create_community", web::get().to(index)) + .route("/communities/page/{page}", web::get().to(index)) + .route("/communities", web::get().to(index)) + .route("/post/{id}/comment/{id2}", web::get().to(index)) + .route("/post/{id}", web::get().to(index)) + .route("/c/{name}/sort/{sort}/page/{page}", web::get().to(index)) + .route("/c/{name}", web::get().to(index)) + .route("/community/{id}", web::get().to(index)) + .route( + "/u/{username}/view/{view}/sort/{sort}/page/{page}", + web::get().to(index), + ) + .route("/u/{username}", web::get().to(index)) + .route("/user/{id}", web::get().to(index)) + .route("/inbox", web::get().to(index)) + .route("/modlog/community/{community_id}", web::get().to(index)) + .route("/modlog", web::get().to(index)) + .route("/setup", web::get().to(index)) + .route( + "/search/q/{q}/type/{type}/sort/{sort}/page/{page}", + web::get().to(index), + ) + .route("/search", web::get().to(index)) + .route("/sponsors", web::get().to(index)) + .route("/password_change/{token}", web::get().to(index)) + // Websocket .service(web::resource("/api/v1/ws").to(chat_route)) - // .service(web::resource("/api/v1/rest").route(web::post().to(||{}))) - .service(web::resource("/").to(index)) + // NodeInfo .route("/nodeinfo/2.0.json", web::get().to(nodeinfo::node_info)) .route( "/.well-known/nodeinfo", web::get().to(nodeinfo::node_info_well_known), ) + // RSS .route("/feeds/{type}/{name}.xml", web::get().to(feeds::get_feed)) - // TODO: probably need a different function for this (or just handle all of /feeds? - // TODO: would be nice to use ListingType, but that doesnt include user .route("/feeds/all.xml", web::get().to(feeds::get_all_feed)) - // static resources - .service(actix_files::Files::new("/static", front_end_dir())) }) .bind((settings.bind, settings.port)) .unwrap() diff --git a/ui/src/index.tsx b/ui/src/index.tsx index 2e50db88..41404f4b 100644 --- a/ui/src/index.tsx +++ b/ui/src/index.tsx @@ -38,11 +38,11 @@ class Index extends Component {
+ - diff --git a/ui/src/utils.ts b/ui/src/utils.ts index 1bbda3aa..98645fe3 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -197,7 +197,7 @@ export async function getPageTitle(url: string) { export function debounce( func: any, - wait: number = 500, + wait: number = 1000, immediate: boolean = false ) { // 'private' variable for instance