Skip to content

Commit

Permalink
Only use remix response code when AdonisJS response code is 200 (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarle authored Oct 23, 2024
1 parent e78d680 commit e80a1c8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/adapter/src/remix_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ export function createRemixRequest(req: AdonisRequest, res: AdonisResponse): Req
export async function sendRemixResponse(ctx: HttpContext, webResponse: Response) {
const res = ctx.response
res.response.statusMessage = webResponse.statusText
res.status(webResponse.status)
if (res.getStatus() === 200) {
res.status(webResponse.status)
}

debug('Commit session early for remix response')
ctx.session?.commit()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { LoaderFunctionArgs } from '@remix-run/node'

export const loader = async ({ context }: LoaderFunctionArgs) => {
const { http } = context

http.response.redirect('/login')

return {
message: 'Hello, world!'
}
}

export default function Page() {
return (
<div>
This should not be visible
</div>
)
}
6 changes: 6 additions & 0 deletions packages/reference-app/tests/browser/data_loading.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ test('basic page with no loader', async ({ visit }) => {
await page.screenshot({ path: 'tests/screenshots/root.png' })
})

test('adonisjs redirect', async ({ visit }) => {
const page = await visit('/adonis_redirect')

await page.waitForURL('/login')
})

test('basic page with loader', async ({ visit, assert }) => {
const page = await visit('/profile')

Expand Down

0 comments on commit e80a1c8

Please sign in to comment.