Skip to content

localhost is not allowed to access #27

Closed
@gcomesana

Description

@gcomesana

Hi there
yes, I've read the 'Usage' section of the readme and checking the previous issues, and I have a quite opposite issue than Issue #19.
I have the API built using Rails 3 and the swagger-ui, both in the same machine, API responding on port 3003 (by running rails -p 3003 app-api), swagger-ui in the localhost/~user/Sites and, in addtition, in another_computer/~user/public_html, for remote testing purposes. In both cases, the API funcitons are listed ok, but it is impossible to make requests, I always get in debugger the (in)famous

submitting http://localhost:3003/api/uniprot/status.json
XMLHttpRequest cannot load http://localhost:3003/api/uniprot/status.json. Origin http://localhost is not allowed by Access-Control-Allow-Origin.

I have at the top of the file defining the API:

before do
    header['Access-Control-Allow-Origin'] = '*'
    header['Access-Control-Request-Method'] = '*'
    header['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS, PUT, PATCH, DELETE'
    header['Access-Control-Allow-Headers'] = 'true'
end

It is more than it is indicated at the docs, but after reading a couple of forum I just wanted to be sure.
And it is working OK if I use the online swagger-ui service...

I know I am missing something but I can't figure out what. can anybody light me up to solve this (annoying) issue??

Cheers and sorry if this is an silly (and repeating) issue.

w i l l y

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions