forked from nuxt/docs
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from jicjjang/ko/api/pages-middleware
ko/api/pages-middleware
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
title: "API: middleware 프로퍼티" | ||
description: 어플리케이션의 특정 페이지에 대한 미들웨어 설정. | ||
--- | ||
|
||
# middleware 프로퍼티 | ||
|
||
- 타입: `String` or `Array` | ||
- Items: `String` | ||
|
||
어플리케이션의 특정 페이지에 대한 미들웨어 설정. | ||
|
||
예제: | ||
|
||
`pages/secret.vue` | ||
```html | ||
<template> | ||
<h1>비밀 페이지</h1> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
middleware: 'authenticated' | ||
} | ||
</script> | ||
``` | ||
|
||
`middleware/authenticated.js` | ||
```js | ||
export default function ({ store, redirect }) { | ||
// 사용자가 인증을 하지 않은 경우. | ||
if (!store.state.authenticated) { | ||
return redirect('/login') | ||
} | ||
} | ||
``` | ||
|
||
더 많은 middleware에 대해 배우고 싶으시다면, [middleware 가이드](/guide/routing#middleware)를 참고해주시기 바랍니다. |