Skip to content

"add project to machine" button does not work cross-domain #26

@dcferreira

Description

@dcferreira

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions