Good afternoon,
What is the correct way to handle OPTIONS requests, when running a gRPC endpoints?
From the latest release notes
https://cloud.google.com/endpoints/docs/release-notes I saw that for ESP to accept these requests, allow_cors must be present in the api_configuration.
My configuration setup looks as follows:
type: google.api.Service
config_version: 3
name: app.endpoints.my-project.cloud.goog
endpoints:
- name: app.endpoints.my-project.cloud.goog
allow_cors: true
title: Users
apis:
- name: endpoints.users.User
usage:
rules:
- selector: endpoints.users.User.Login
allow_unregistered_calls: true
And the http mapping is written in the proto file as follows:
syntax = "proto3";
package endpoints.users;
option go_package = "proto";
import "google/api/annotations.proto";
service User {
rpc Login (LoginRequest) returns (AuthResponse) {
option (google.api.http).post = "/api/v2/users/login";
}
}
message LoginRequest {
string email = 1;
string password = 2;
}
message AuthResponse {
string token = 1;
}
However when making a OPTIONS request, I get a 404 response.
This makes sense, as I have not defined an option for this request method, but when I add
option (google.api.http).option = "/api/v2/users/login"; to the rpc, during the go code generation I get an error that Option "(google.api.http).options" unknown.
I tried adding it using the custom option, however this did not yield any results either.
Currently, to support CORS I'm intercepting the OPTIONS request in the ESP configuration, but this feels a a very hacky way to do things.
Any pointers to solve this problem will be highly appreciated.
Vito