Customize Path for AJAX calls

enhancement
front-end

(Henninglebbaeus) #1

We are using Prodigy in our organization where we deploy it to a Google App Engine environment and have users access via a certain URL. What we noticed is that the frontend makes all calls to the backend at the root path. So if I deploy it to mydomain.com, the app will request new questions at mydomain.com/get_questions. It even does so if we deploy the app to mydomain.com/project123, which means all the AJAX requests fail in that case.

It would be great if there would be a way to modify the base path to which requests are made. So in the above example it would request new questions at mydomain.com/project123/get_questions. Our current approach is to deploy different projects to different subdomains, but it is a bit cumbersome in terms of other processes (like authentication).

It may also be the case there is an obvious solution to this problem, but it currently is not obvious to me :slight_smile:


(Ines Montani) #3

Yes, at the moment, this is difficult – sorry about that. Especially if we want to support the same configuration workflow via the prodigy.json. When you start up the app, Prodigy makes a request to the server to fetch the settings – but in order to do this, it obviously needs the base path (which it won’t have if it’s only provided in the settings). Recompiling the app for each base path isn’t really a good solution either, and we also want to avoid making the user run two separate processes per session (server and web app). So in order to support custom base paths, we’ll have to refactor quite a bit of the web app and REST API logic (or add a hack to inject this information via the static resources, which is less elegant).

For our own Prodigy-powered projects, we normally use subdomain-based routing, which works pretty well :slightly_smiling_face: So if that’s an option for you, you could use this as a workaround for now.


(Henninglebbaeus) #4

Could something like this work:

Put the path to the backend in a query parameter when making the GET request to the prodigy Web App. Then make all the AJAX calls go to this path. If the query parameter is missing, assume it’s the same path as the Web App (current situation).

mydomain.com/?backend=mydomain.com/backends/project123

This would also separate Prodigy into one static web app and several REST backends, while the simple local developer usage is preserved. I guess it would need a flag or config setting to tell the backend server to listen on the right path.

The settings are returned by the /project handler, right? Or is there some other magic happening in the JS part?