The Problem
When uploading a file using the Go Blobstore API, the success path redirects to the wrong appengine module. Here is a more visual description of the problem:
- User lands on the upload page of module A:
http://A.my-appengine-app.com/upload
- User's browser makes a request to the module for an upload session:
http://A.my-appengine-app.com/upload/session
- Module A defines a handler for
/upload/session
which runs the following Go code:url, err := blobstore.UploadURL(c, "/upload/success")
- The method returns a URL, similar to:
http://A.my-appengine-app.com/_ah/upload/[some long hash]/
- This URL is relayed back to the user's browser and inserted into the
action
of a<form>
. - The user submits a multipart
POST
request to the URL - Whatever handles the URL (some non-user-space appengine handler), attempts to redirect back to
/upload/success
This is where things get weird. In development, the server redirects to "/upload/success" in module A. In production, the server redirects to the main module, which we can call B for now. I can tell this is happening because I am getting a 404
in my web console and the logs indicate that the request is being made to module B. I've even gone so far as to explicitly pass the hostname as part of the success path (step #3), but to no effect.
Current Solution (Not Ideal)
It seems my only recourse is to define a handler in module B to handle the request as module A would. Since the goapp architecture globs all the modules together, this isn't the worst tradeoff in the world, but it's semantically wrong given that modules are supposed to be vertically independent. If anyone has any idea how to work around this, I'd be obliged. For now, I'll take the aforementioned approach.