Skip to content

Commit

Permalink
Handle the case when acceptsLanguages() returns false
Browse files Browse the repository at this point in the history
  • Loading branch information
MrOrz committed Jun 11, 2018
1 parent 0cb80e1 commit 2421e28
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ app.prepare().then(() => {
server.use(async (ctx, next) => {
switch (ctx.path) {
case '/': {
const lang = ctx.acceptsLanguages(['zh', 'en']).replace('zh', 'tw');
const lang = (ctx.acceptsLanguages(['zh', 'en']) || 'en').replace(
'zh',
'tw'
);
await send(ctx, `./static/index-${lang}.html`);
break;
}
Expand Down

0 comments on commit 2421e28

Please sign in to comment.