non_field_errors: ["State could not be found in server-side session data."]
I have deployed my django rest framework app on Railway. I'm using djoser with social-auth-app-django. My app works on local host. But I'm getting above error when I make post request to /auth/o/google-oauth2/?state=''..."&code=''..." after getting state and code from google authorization url.
34 Replies
Project ID:
286dccfe-bf85-48fe-ae80-ab24c5a80716
286dccfe-bf85-48fe-ae80-ab24c5a80716
@Brody Can you please help me here?
please no pings #🛂|readme #5
I will need to see your deployment logs https://bookmarklets.up.railway.app/log-downloader/
and it would be very useful to see your repo as well
When i make a request to the server I don't see any change in logs in observability tab. I also tried railway logs CLI command there also I didn't see any cahnge in logs. Did I miss some thing in my django rest framework app??
it's possible, but some common things to first check would be
- is railway using the same python version as you use locally
- are you pinning your dependencies to the same version you have installed locally
- have you forgotten to add some environment variables for google auth
didn't understand your second point.
I'm using 3.10.11 in dev and the app is deployed using dockerfile and in dockerfile I have mentioned this "FROM python:3.10". So, I guess python version is not an issue.
I have also checked the environments they are the same for prodution and local dev
when you have your packages that you install like
these install under a version
and in your requirements.txt it's common practice to specify the version you had locally
so you know that version was stable with your code
Okay. Let me try that
just do
and look for django
and just literally copy that and have the == with the version behind
In production I'm using via requirements.txt file only
How do I check if my python version in prod in rialway??
it will install these
so if this works for you in local dev
then the depends shouldnt be the issue
How can I see the deatiled log for django rest framewrk in railway?
do not do pip freeze unless you are using a venv, pip freeze will place all the dependencies installed on the computer into the requirements.txt file
are there no logs in your deployment logs?
it does not
ir just prints
if you pass an extra xarg yes
I know it just prints, but if you redirect the output to the requirements.txt file then it will
and that's hardly ever desirable
I'm using venv
I'm sharing the loggs now
it's printed in the build table at the top of the build logs
in the build logs i see this line
#3 [internal] load metadata for docker.io/library/python:3.10
you are using a dockerfile, this would have been very good information to know, please send the dockerfile
In venev I'm using Python 3.10.11
FROM python:3.10
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /app
COPY . /app/
RUN python3 -m venv venv
RUN . venv/bin/activate
RUN apt-get update && apt-get install -y \
build-essential \
libpoppler-cpp-dev \
pkg-config \
python3-dev \
&& apt-get clean
RUN pip install --no-cache-dir -r requirements.txt
CMD python manage.py migrate && gunicorn core.wsgi:application
do you build with this dockerfile locally
no
locally I run the server inside venv
okay then at this point I am confident in saying that this is a code issue
But running server locally inside venv I don't get this error
only In prod this happening in railway
unfortunately that doesn't rule out a code issue
you build with a dockerfile, you have full control over how your app is built and ran, this isn't an issue with railway
ANy guess how can I solve this?
stackoverflow?
these threads are generally not for code issues, and more for help with the platform
I understand. I tried stackover flow. no clear answer there.
this issue wouldn't be isolated to railway, please do further research
is there any way to see more detailed logs where exactly the error is happning. instead of just what we see in this ss.
if you dont see detailed error logs then your code is simply not logging the errors
make sure you log errors to stderr without buffering