I am writing a Kotlin app to be deployed on Google App Engine. I am using a Gradle plugin to do the actual deploy to GAE. Everything had been working fine; I successfully deployed a hello-world application to GAE.
However, now I need to add a Filter, specifically the com.googlecode.objectify.ObjectifyFilter
. But once I add this filter to my app.yaml file, the app will no longer deploy. Instead, it gives me an error telling me that "filter" was not an expected attribute.
Here is my app.yaml file:
runtime: java11
handlers:
- url: /*
filter: com.googlecode.objectify.ObjectifyFilter
Here is the error:
> Task :webservice:appengineDeployAll FAILED
ERROR: (gcloud.app.deploy) An error occurred while parsing file: [C:\Users\mathew\Documents\fooApp\webservice\build\staged-app\app.yaml]
Unexpected attribute 'filter' for object of type URLMap.
in "C:\Users\mathew\Documents\fooApp\webservice\build\staged-app\app.yaml", line 4, column 11
What am I doing wrong? How do I configure a filter in a GAE app?
You must specify the Filter class in your deployment descriptor file. Then you can set your headers inside that filter class. Here you can find more details about Filters in App Engine.
Something to keep in mind is that these filters do not work for static resources requests for your css and js.files.