Skip to content

Commit

Permalink
fix: build 的時候沒有 accept-language,需拿掉
Browse files Browse the repository at this point in the history
  • Loading branch information
sexyoung committed Aug 7, 2023
1 parent bcdf3d9 commit 5707bcf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ jobs:
deploy:
name: 🚀 Deploy
runs-on: ubuntu-latest
needs: [lint, typecheck, vitest]
# needs: [lint, typecheck, vitest, cypress]
needs: [lint, typecheck, vitest, cypress]
# only build/deploy main branch on pushes
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}

Expand Down
20 changes: 12 additions & 8 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,19 @@ export const loader = async ({ request, params }: LoaderArgs) => {
}
: {};

// 如果 params.lang 為空,判斷語系是否為英文,否則轉頁
if (!params.lang && !cookie?.keepLang) {
const browserLang =
request.headers
.get("accept-language")
?.split(",")
.map((l) => l.split(";").shift())
.shift() || "";
const browserLang =
request.headers
.get("accept-language")
?.split(",")
.map((l) => l.split(";").shift())
.shift() || "";

// 如果 params.lang 為空,判斷語系是否為英文,否則轉頁
if (
!params.lang &&
!cookie?.keepLang &&
request.headers.get("accept-language")
) {
if (!["en-US", "en"].includes(browserLang)) {
return redirect(`/${browserLang}`, init);
}
Expand Down

0 comments on commit 5707bcf

Please sign in to comment.