Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request from another container #18

Open
KaNuNSuZoFLu opened this issue Nov 18, 2018 · 2 comments
Open

Request from another container #18

KaNuNSuZoFLu opened this issue Nov 18, 2018 · 2 comments

Comments

@KaNuNSuZoFLu
Copy link

I‘m getting an error (Cross origin) when I am doing a request from another container. How can I enable cors?

@jgontrum
Copy link
Owner

Hmm, interestingly I haven't run into that problem myself so far. How exactly are you making your request?

A fix could be adding this middleware falconry/falcon#1220 (comment) to the Python code here

APP = falcon.API()

I don't know how soon I have time to integrate it, so feel free to make a PR :)

@KaNuNSuZoFLu
Copy link
Author

Hi, so I was on the right path. exactly there I wanted to add the cross_origin but I was not sure, if the mistake is not my request itself. I tried to make an ajax request.

first of all i created the container a bit different, because I want to make the request from another docker container, so i created the container like

docker run -it -p "0.0.0.0:8080:80" jgontrum/spacyapi:en_v2

I have a nodejs container, where my application is hosted on. the request is done from a javascript

$.ajax({
type: "PUT",
url: "http://:8080/ent",
contentType: 'application/json; charset=utf-8',
data: JSON.stringify({
"text": "When Sebastian Thrun started working on self-driving cars at Google in 2007, few people outside of the company took him seriously.",
"model": "en"
}),
dataType: 'json',
async: true,
success: function() {
console.log("success");
},
error: function() {
console.log("error");
}
});

I think the request should be right. and the error which is given is:

Access to XMLHttpRequest at 'http://<my_ip>:8080/ent' from origin 'http://<my_ip>:<nodejs_port>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants