-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Hi,
Issue #15 implements a button to add a project to a FGMachine, but the way it is implemented only works when both FGLab and FGMachine have the same domain name.
This is the way the HTTP request is currently made:
$.ajax({
url: address + "/projects",
type: "PUT",
contentType: "application/json",
data: JSON.stringify({project_id: id})
})
However, according to the documentation for contentType in http://api.jquery.com/jquery.ajax/,
Note: For cross-domain requests, setting the content type to anything other than application/x-www-form-urlencoded, multipart/form-data, or text/plain will trigger the browser to send a preflight OPTIONS request to the server.
This means that currently if address is different from the address you're using to access FGLab, an HTTP OPTIONS request will be sent (which as far as I understood FGMachine doesn't know how to deal with), and no PUT request is ever sent.
I ran into this problem by running FGLab and FGMachine in docker containers, and accessing FGLab's UI at http://localhost:5080.
I temporarily fixed this by changing the contentType to text/plain, but this is not a good solution.