Skip to content

Commit

Permalink
docs: use html extension and format
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Sep 25, 2020
1 parent 1d50228 commit 8ae5d0f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 42 deletions.
34 changes: 17 additions & 17 deletions docs/fr/guide/essentials/history-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Le mode par défaut de `vue-router` est le _mode hash_. Il utilise la partie has

Pour nous passer du hash, nous pouvons utiliser le **mode historique** qui utilisera l'API `history.pushState` afin de permettre une navigation sans rechargement de page :

``` js
```js
const router = new VueRouter({
mode: 'history',
routes: [...]
Expand Down Expand Up @@ -49,21 +49,23 @@ const http = require('http')
const fs = require('fs')
const httpPort = 80

http.createServer((req, res) => {
fs.readFile('index.htm', 'utf-8', (err, content) => {
if (err) {
     console.log(`Impossible d'ouvrir le fichier "index.htm"`)
}
http
.createServer((req, res) => {
fs.readFile('index.html', 'utf-8', (err, content) => {
if (err) {
console.log(`Impossible d'ouvrir le fichier "index.html"`)
}

res.writeHead(200, {
'Content-Type': 'text/html; charset=utf-8'
})

res.writeHead(200, {
'Content-Type': 'text/html; charset=utf-8'
res.end(content)
})

res.end(content)
})
}).listen(httpPort, () => {
console.log('Le serveur écoute à : http://localhost:%s', httpPort)
})
.listen(httpPort, () => {
console.log('Le serveur écoute à : http://localhost:%s', httpPort)
})
```

### Node.js avec Express
Expand Down Expand Up @@ -126,12 +128,10 @@ Ajouter ceci à votre fichier `firebase.json` :

Il y a une limitation a tout ceci. Votre serveur ne renverra plus les erreurs 404 des chemins qui ne sont pas trouvés puisqu'il va servir à présent le fichier `index.html`. Pour contourner ce problème, vous pouvez implémenter une route concordant avec toutes les adresses en 404 dans votre application Vue :

``` js
```js
const router = new VueRouter({
mode: 'history',
routes: [
{ path: '*', component: NotFoundComponent }
]
routes: [{ path: '*', component: NotFoundComponent }]
})
```

Expand Down
47 changes: 22 additions & 25 deletions docs/kr/guide/essentials/history-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

해시를 제거하기 위해 라우터의 **history 모드** 를 사용할 수 있습니다. `history.pushState` API를 활용하여 페이지를 다시 로드하지 않고도 URL 탐색을 할 수 있습니다.

``` js
```js
const router = new VueRouter({
mode: 'history',
routes: [...]
Expand Down Expand Up @@ -43,28 +43,29 @@ location / {
#### Native Node.js

```js
const http = require("http")
const fs = require("fs")
const http = require('http')
const fs = require('fs')
const httpPort = 80

http.createServer((req, res) => {
fs.readFile("index.htm", "utf-8", (err, content) => {
if (err) {
console.log('We cannot open "index.htm" file.')
}
http
.createServer((req, res) => {
fs.readFile('index.html', 'utf-8', (err, content) => {
if (err) {
console.log('We cannot open "index.html" file.')
}

res.writeHead(200, {
"Content-Type": "text/html; charset=utf-8"
})
res.writeHead(200, {
'Content-Type': 'text/html; charset=utf-8'
})

res.end(content)
res.end(content)
})
})
.listen(httpPort, () => {
console.log('Server listening on: http://localhost:%s', httpPort)
})
}).listen(httpPort, () => {
console.log("Server listening on: http://localhost:%s", httpPort)
})
```


#### Express와 Node.js

Node.js/Express의 경우 [connect-history-api-fallback 미들웨어](https://github.com/bripkens/connect-history-api-fallback)를 고려해보세요.
Expand All @@ -87,29 +88,25 @@ Node.js/Express의 경우 [connect-history-api-fallback 미들웨어](https://gi
</rule>
</rules>
</rewrite>
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="404" path="/survey/notfound" responseMode="ExecuteURL" />
<error statusCode="404" path="/survey/notfound" responseMode="ExecuteURL" />
<error statusCode="500" path="/survey/error" responseMode="ExecuteURL" />
</httpErrors>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
```


## 주의 사항

주의 사항이 있습니다. 여러분의 서버는 404 에러를 보고하지 않을 것입니다. 왜냐하면 모든 발견되지 않은 경로가 이제 `index.html` 파일을 제공하기 때문입니다. 이 문제를 해결하려면 Vue 앱에서 catch-all 라우트를 구현하여 404 페이지를 표시해야합니다.


``` js
```js
const router = new VueRouter({
mode: 'history',
routes: [
{ path: '*', component: NotFoundComponent }
]
routes: [{ path: '*', component: NotFoundComponent }]
})
```

Expand Down

0 comments on commit 8ae5d0f

Please sign in to comment.