Search code examples
javagoogle-app-enginehttp-redirectgoogle-cloud-dns

Prevent Google App Engine from serving from appspot.com


I'm serving my app from a custom domain. I don't want it to be available at the appspot.com domain. What's the easiest way to achieve this? I'd like to be able to do it at the console level, but I have feeling I'll have to configure it in the app. The app is written in Java. Thanks.


Solution

  • If you want to completely deny any access via the appspot domain.

    Use a custom ServletFilter to check the HttpServletRequest.getRequestURL() to see if it matches the appspot.com domain and return a 404 Not Found.

    The filters are applied in the order they are listed in the web.xml so make sure this one is the first one.