Menu

1.1.8

提示

版本号请查看 package.json 文件的 version 字段

修复 LanguageDetectionAlert 多语言

更新层级:1.1.7+ 必须修改;1.1.7- 不要修改。

1.1.7 升级多语言结构后,LanguageDetectionAlert 获取多语言文案的地方没有修改,因此修复。

components/LanguageDetectionAlert.tsx
  // const messages = require(`@/i18n/messages/${currentLocale}.json`); // remove
  const messages = require(`@/i18n/messages/${currentLocale}/common.json`); // add

登录验证共享 isValidRedirectUrl

更新层级:可选修改。

该变动是为了同步不同登录方式的校验流程。

app/auth/confirm/route.ts 里的 URL 校验方法 isValidRedirectUrl 转移到独立的文件 app/auth/utils.ts

app/auth/utils.ts
const ALLOWED_REDIRECT_HOSTS = (
  process.env.NODE_ENV === 'development'
    ? (process.env.ALLOWED_REDIRECT_HOSTS?.split(',') || [])
    : []
).concat(process.env.NEXT_PUBLIC_SITE_URL!).filter(Boolean) as string[]
 
export function isValidRedirectUrl(url: string): boolean {
  try {
    if (url.startsWith('/api/')) {
      return false;
    }
 
    if (url.startsWith('/')) {
      return true;
    }
 
    const parsedUrl = new URL(url)
 
    return ALLOWED_REDIRECT_HOSTS.includes(parsedUrl.host)
  } catch {
    return false
  }
}

app/auth/callback/route.tsapp/auth/confirm/route.ts 里使用相同的 URL 校验:

let next = searchParams.get('next') ?? '/'
next = next == 'null' ? '/' : next
 
// 新增
if (!isValidRedirectUrl(next)) {
  console.error('Invalid redirect URL')
  return NextResponse.redirect(new URL(`/redirect-error?code=invalid_redirect`, origin))
}

优化图片上传失败的处理

更新层级:可选修改。

该变动是为了在图片上传失败后将已选图片清空。

app/[locale]/(protected)/dashboard/(admin)/blogs/ImageUpload.tsx
if (
  !presignedUrlActionResponse.success ||
  !presignedUrlActionResponse.data
) {
  setPreviewUrl(null); // add, Line 70
  toast.error(t("uploadError"), {
    description:
      presignedUrlActionResponse.error || t("presignedUrlError"),
  });
  return "";
}
 
// ...
try {
  // ...
} catch (error) {
  setPreviewUrl(null); // add, Line 107
  console.error("MDX Image Upload failed:", error);
  toast.error(getErrorMessage(error) || t("upload.uploadErrorUnexpected"));
} finally {
  // ...
}

删除 orders 表的 period_start 和 period_end 字段

更新层级:无需修改。

该变动是废弃掉没有意义的字段,保留与否都不影响功能,建议已 clone 的代码无需修改。

  1. 删除 data/orders.sqlperiod_startperiod_end 定义

  2. 删除 lib/stripe/webhook-handlers.ts 文件里 handleInvoicePaid 内部涉及 period_startperiod_end 字段的行:

// period_start: invoice.period_start ? new Date(invoice.period_start * 1000).toISOString() : null, // remove
// period_end: invoice.period_end ? new Date(invoice.period_end * 1000).toISOString() : null, // remove
  1. Supabase 控制台 Table Editor 删除 period_startperiod_end 字段

  2. 更新本地 Supabase 类型定义:

supabase gen types typescript --project-id <your-project-id> --schema public > lib/supabase/types.ts

年付订阅示例

示例代码:subscription-yearly分支

文档地址:https://nexty.dev/docs/guide/payment/yearly-subscription