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.
Asked
Active
Viewed 810 times
2 Answers
1
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.

Community
- 1
- 1
-
Thanks. In the end I did it in the doGet, but I'd imagine a filter would be more efficient. – keith.uk May 27 '15 at 11:28
-
that means you have to modify the `doGet()` in every servlet, and what about `Servlets` you do not have the source to? – May 27 '15 at 12:39
-
Yes. You're right. The situation that I'm in is that I have an existing project written in GWT. It's going to be re-written from the ground up without GWT. So, to test the redirection, I just ran it on a simple very simple App. When I come to do the re-write, I'll most likely use your solution. – keith.uk May 28 '15 at 22:36
0
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]");
}
}

keith.uk
- 75
- 4