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

Docker Container 400 bad request error #81

Open
njseeber1 opened this issue May 7, 2020 · 5 comments
Open

Docker Container 400 bad request error #81

njseeber1 opened this issue May 7, 2020 · 5 comments

Comments

@njseeber1
Copy link

Hey, when spinning up the docker container you have in the code I always get a 400 Bad Request error when making an API request that is in the documentation. Any idea on what might be going on there?

@crobertsbmw
Copy link
Owner

crobertsbmw commented May 7, 2020 via email

@njseeber1
Copy link
Author

Gotcha, thanks for the update! I Appreciate it!

@neno91
Copy link

neno91 commented Jan 16, 2021

TBH, I don’t remember setting up any docker stuff. I remember tinkering with docker like 4 years ago, but my familiarity with docker probably rounds to 0. I should probably just remove anything referencing docker in the code.

On Wed, May 6, 2020 at 6:11 PM Nick Seeber @.***> wrote: Hey, when spinning up the docker container you have in the code I always get a 400 Bad Request error when making an API request that is in the documentation. Any idea on what might be going on there? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#81>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMQLHT3BVXQF2VGSCJYKNLRQH4EVANCNFSM4M24D5VA .

Hello

There is nothing wrong with the dockerfile.

I'ts just the CORS policy thats blocking your requests.

You need to edit spades/settings.py file and insert your host to ALLOWED_HOSTS
ALLOWED_HOSTS = ['.deckofcardsapi.com', '127.0.0.1', 'yourhosthere']

Best regards
Jørgen S.

@crobertsbmw
Copy link
Owner

I know this is super old, but I dug into this a little bit today. I couldn't find an error with CORS, but I was able to find a CSRF error when trying to do post requests. I removed the CSRF validation, and now you should be able to make cross site requests. Let me know if that's not he case.

@neno91
Copy link

neno91 commented Jan 21, 2021

I know this is super old, but I dug into this a little bit today. I couldn't find an error with CORS, but I was able to find a CSRF error when trying to do post requests. I removed the CSRF validation, and now you should be able to make cross site requests. Let me know if that's not he case.

Thank you :)
For me adding my hostname/domain to the allowed_hosts fixed the 400 error.

I cant say if thats the same issue that the thread starter was experiencing. But normally docker acts the same for all parties.

I would assume that you could reproduce the error by just spinning up a docker container on another host and then try to access it.

I was wrong to say its the cors policy. Seems like django now requires the hosting domain to be in the list. https://docs.djangoproject.com/en/3.1/ref/settings/#std:setting-ALLOWED_HOSTS

Best regards
Jørgen S.

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

No branches or pull requests

3 participants