CORS Error in Google App Engine on java server

The issue is that the CORS needs to be allowed on the app engine app.

This can be done on the app.yaml by adding a handler to include the CORS headers like this:

runtime: java11
instance_class: F4
vpc_access_connector:
  name: projects/<project_id>/locations/<location>/connectors/<connectors_name>
- url: /.*
  script: auto
  http_headers:
    Access-Control-Allow-Origin: *

This will allow the CORS calls to come from any domain, if you want to have it more spefic to only allow your firebase app you can change the * to the firebase App URL


You need to add Access-Control-Allow-Origin to the headers and need to respond to the request Please try with the below code blocks

 header := w.Header()
 header.Add("Access-Control-Allow-Origin", "*")

Respond to the initial request

if r.Method == "OPTIONS" {
    w.WriteHeader(http.StatusOK)
    return
}