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

Fixes error in theme switcher and adds samesite setting in set-cookie header #113

Conversation

szpeter80
Copy link
Contributor

Currently switching themes results in both server-side and client side errors.

Server side:

ERROR:app:Exception on /set_theme/dark [GET]
Traceback (most recent call last):
File "/root/picamera2-WebUI/.venv/lib/python3.11/site-packages/flask/app.py", line 1511, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/picamera2-WebUI/.venv/lib/python3.11/site-packages/flask/app.py", line 920, in full_dispatch_request
return self.finalize_request(rv)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/picamera2-WebUI/.venv/lib/python3.11/site-packages/flask/app.py", line 939, in finalize_request
response = self.make_response(rv)
^^^^^^^^^^^^^^^^^^^^^^
File "/root/picamera2-WebUI/.venv/lib/python3.11/site-packages/flask/app.py", line 1212, in make_response
raise TypeError(
TypeError: The view function for 'set_theme' did not return a valid response. The function either returned None or ended without a return statement.

The root cause is that the route ends with a bare "return", which probably translates to "return None", and that makes Flask erroring out. The error is reported back to the client with an 5xx error code, which makes it log an error on the JS console.

Changing the return statement to return the "ok" object makes both server and client happy :)

Also, on the console there were messages about the cookie samesite setting missing, now it is set explicitly to the most permissive value.

+ add SameSite setting to session cookie
@monkeymademe monkeymademe merged commit 1024c49 into monkeymademe:main Dec 29, 2024
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

Successfully merging this pull request may close these issues.

2 participants