GCP internal Load balancer throwing 405 - Method Not Allowed

128 views Asked by At

I have two cloud run service. One is a proxy which is used to forward the traffic to a cloud storage bucket for a angular static website and another is to provide data(Used as an API). I have created a internal ILB and created path based rules to distribute traffic two two different backend. When I am directly hitting the api by using the ILB url from curl it is giving the data. Both the static web site and api server by the same load balancer But when I am trying to to access the static files which calls the api(from javascript) then I am getting a error which says 405 - Method Not Allowed. It is a post request. I can see the pay load also From the browser I can see

Request URL:
https://something.com/api/id
Request Method:
POST
Status Code:
405
Remote Address:
*.*.*.*.*:443
Referrer Policy:
strict-origin-when-cross-origin

Terraform code

# URL map
resource "google_compute_region_url_map" "url_map_euw3" {
  name    = "${var.lb_prefix}-ilb-regional-url-map"
  project = frontend_project.project_id
  region  = "europe-west1"

  default_service = google_compute_region_backend_service.service_euw3["first-cloud-run"].id

  host_rule {
    hosts        = ["*"]
    path_matcher = "default-path-matcher"
  }

   path_matcher {
    name            = "default-path-matcher"
    default_service = google_compute_region_backend_service.service_euw3["first-cloud-run"].id
    path_rule {
      paths   = ["/api/id"]
      service = google_compute_region_backend_service.service_euw3["second-cloud-run"].id
      route_action {
        url_rewrite {
          path_prefix_rewrite = "/id"
        }
      } 
    }
    path_rule {
      paths   = ["/*"]
      service = google_compute_region_backend_service.service_euw3["first-cloud-run"].id
    }
  }

}
0

There are 0 answers