sid027 / dt1-23

1 stars 5 forks source link

Bubble API call not working - CORS #9

Open dylanecoffey opened 10 months ago

dylanecoffey commented 10 months ago

Dear Sid,

My API call from Bubble is not working, I get the following error message:

Access to fetch at 'http://34.155.185.235:5000/chat?input=The_purpose_of_life_is' from origin 'https://dylanecoffey-dt1-23.bubbleapps.io' 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. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

From the research I did, I should modify the main.py file in order to make it work. Is it really the case ?

Thank you very much.

Best,

Dylan

sid027 commented 10 months ago

The main.py has the following like output.headers.add("Access-Control-Allow-Origin", "*"). This should be enough. Maybe you need to enable it on your browser e.g. here?

sid027 commented 10 months ago

@joshlevent can you also check this?

joshlevent commented 10 months ago

Yes, I think that’s right. The python file allows CORS, so if it still doesn’t work it should be a browser issue. Different browsers have completely different ways of solving it so I cannot give a general solution. But in general “mixed content” should be allowed.

e-kartofel commented 10 months ago

Solved in Teams: image

Although this solution requires the user to perform a complex setting operation in their browser, it is specified like this in the Assignment specs. https://user-images.githubusercontent.com/148684734/282239454-e99b57a2-1263-4f1d-91cc-1da9847334ab.png Please @sid027 close the threat if the solution is good.

sid027 commented 9 months ago

related #6