Skip to content

Commit

Permalink
Send Set-Cookie header from nextjs response to user
Browse files Browse the repository at this point in the history
and bump version 3.1.0
  • Loading branch information
danialkeimasi committed Jun 24, 2024
1 parent d7a8a91 commit 84b9867
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion django_nextjs/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.0.0"
__version__ = "3.0.1"
12 changes: 7 additions & 5 deletions django_nextjs/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ async def handle(self, body):
headers = {k.decode(): v.decode() for k, v in self.scope["headers"]}
async with aiohttp.ClientSession(headers=headers) as session:
async with session.get(url) as response:
await self.send_headers(
headers=[
(b"Content-Type", response.headers["content-type"].encode()),
]
)
nextjs_response_headers = [
(name.encode(), value.encode())
for name, value in response.headers.items()
if name.lower() in ["content-type", "set-cookie"]
]

await self.send_headers(headers=nextjs_response_headers)
async for data in response.content.iter_any():
await self.send_body(data, more_body=True)
await self.send_body(b"", more_body=False)
Expand Down
1 change: 1 addition & 0 deletions django_nextjs/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def _get_nextjs_response_headers(headers: MultiMapping[str]) -> Dict:
"Location",
"Vary",
"Content-Type",
"Set-Cookie",
],
)

Expand Down

0 comments on commit 84b9867

Please sign in to comment.