Skip to content

Conversation

@SupakornNetsuwan
Copy link
Collaborator

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented May 24, 2025

⚠️ No Changeset found

Latest commit: 5c53f57

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment on lines 80 to 83
routes: {
notFound: { view: () => <NotfoundPage redirectURL="/admin/collections" /> },
notAuthorized: { view: () => <NotAuthorizedPage redirectURL="/admin/auth/login" /> },
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, แต่ว่า key ของ routes ควรจะเป็น path มากกว่า e.g. /admin/:id เพราะฉะนั้น ถ้าอยากเพิ่ม option ให้ user แก้ 401 / 404 ได้ ให้ทำผ่าน props ของ NextJsServerConfig แทนดีกว่า เช่น

// ฝั่ง user ใช้
const serverConfig = defineNextJsServerConfig(_serverConfig, {
  ui: {
    notFound: ...
    notAuthorized: ...
  }
})

// ฝั่งเรา implement pages/root.tsx

return serverConfig.ui.notFound(...)

ชื่อ props เปลี่ยนได้นะ เอาที่เห็นว่าสมควร

Base automatically changed from yu/feat/auth-2 to main May 27, 2025 12:34
Comment on lines +78 to +88
const radixRouter = createRouter<RouterData>({
routes: {
notFound: {
view: () => uiConfig?.notFound || <NotfoundPage redirectURL="/admin/collections" />,
},
notAuthorized: {
view: () =>
uiConfig?.notAuthorized || <NotAuthorizedPage redirectURL="/admin/auth/login" />,
},
},
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

เอาอันนี้ออกด้วย ๆ

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

เอาออกแล้วตัว 404, 403 จะใช้วิธีไหนในการเรียกใช้นะครับ

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ผมเข้าใจว่าเราไปสร้าง config ที่ nextjs wrapper

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ใช้แล้วใน pages/root.tsx

  if (!result) {
    return router.ctx.options.routes!.notFound.view() // TODO: Type safe
  }

  let user: any = {}
  if (result.requiredAuthentication) {
    user = await getUser(props.serverFunction)
    if (!user) {
      return router.ctx.options.routes!.notAuthorized.view() // TODO: Type safe
    }
  }

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