Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sample
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周韬
node-sample
Commits
15fdd928
Commit
15fdd928
authored
Jun 07, 2017
by
Sebastien Chopin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix https + canonical link
parent
0f13c380
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
default.vue
layouts/default.vue
+12
-0
https.js
middleware/https.js
+5
-2
No files found.
layouts/default.vue
View file @
15fdd928
...
...
@@ -19,6 +19,18 @@
</div>
</
template
>
<
script
>
export
default
{
head
()
{
return
{
link
:
[
{
rel
:
'canonical'
,
href
:
`https://hn.nuxtjs.org
${
this
.
$route
.
fullPath
}
`
}
]
}
}
}
</
script
>
<
style
lang=
"stylus"
>
body
font-family -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
...
...
middleware/https.js
View file @
15fdd928
export
default
({
isDev
,
req
,
redirect
})
=>
{
// Redirect to https
if
(
!
isDev
&&
req
&&
!
req
.
connection
.
encrypted
)
{
return
redirect
(
301
,
`https://
${
req
.
headers
.
host
}${
req
.
url
}
`
)
if
(
!
isDev
&&
req
)
{
const
protocol
=
req
.
headers
[
'X-Forwarded-Proto'
]
||
(
req
.
connection
.
encrypted
?
'https'
:
'http'
)
if
(
protocol
===
'http'
)
{
return
redirect
(
301
,
`https://
${
req
.
headers
.
host
}${
req
.
url
}
`
)
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment