keith.uk
keith.uk

Reputation: 75

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.

Upvotes: 3

Views: 837

Answers (2)

keith.uk
keith.uk

Reputation: 75

In the end I did something like this:

public void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws IOException {
    if (req.getRequestURL().toString().startsWith ("http://1-dot-")) {
        resp.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
        resp.setHeader("Location", "[my custom domain]");
    }
} 

Upvotes: 0

user177800
user177800

Reputation:

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.

Upvotes: 1

Related Questions