Skip to content

Commit

Permalink
fix: don't hit API server for /api prefixed paths (#136)
Browse files Browse the repository at this point in the history
Fixes #135
  • Loading branch information
lucacasonato authored Mar 3, 2024
1 parent 7e84263 commit 43e8a0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions terraform/https.tf
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,16 @@ resource "google_compute_url_map" "frontend_https" {
priority = 2
service = google_compute_backend_service.registry_api.self_link
match_rules {
prefix_match = "/api"
prefix_match = "/api/"
}
match_rules {
prefix_match = "/login"
full_path_match = "/login"
}
match_rules {
prefix_match = "/logout"
full_path_match = "/login/callback"
}
match_rules {
full_path_match = "/logout"
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions tools/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ async function handler(req: Request): Promise<Response> {
return res;
}
if (
url.pathname.startsWith("/api") || url.pathname.startsWith("/login") ||
url.pathname.startsWith("/logout")
url.pathname.startsWith("/api/") || url.pathname === "/login" ||
url.pathname === "/login/callback" ||
url.pathname === "/logout"
) {
const apiUrl = `${API_SERVER}${url.pathname}${url.search}`;
const apiRes = await proxy(req, apiUrl);
Expand Down

0 comments on commit 43e8a0a

Please sign in to comment.