Browse Source

reintroduce redirect middleware

TODO: change 302 to 301 if everything works
Brian Wiborg 1 year ago
parent
commit
0fa5c7de1a
2 changed files with 5 additions and 8 deletions
  1. 2
    2
      middleware/redirect-to-non-www.js
  2. 3
    6
      nuxt.config.js

+ 2
- 2
middleware/redirect-to-non-www.js View File

@@ -1,11 +1,11 @@
1
-module.exports = function (req, res, next) {
1
+export default function (req, res, next) {
2 2
   const host = req.headers.host
3 3
   const url = req.url
4 4
   const env = process.env.NODE_ENV
5 5
   const canonicalDomain = 'flux.fail'
6 6
 
7 7
   if (env === 'production' && host !== canonicalDomain) {
8
-    res.writeHead(301, { Location: 'https://' + canonicalDomain + url })
8
+    res.writeHead(302, { Location: 'http://' + canonicalDomain + url })
9 9
     return res.end()
10 10
   }
11 11
 

+ 3
- 6
nuxt.config.js View File

@@ -1,9 +1,6 @@
1 1
 const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin')
2 2
 const pkg = require('./package')
3 3
 
4
-// language files
5
-const lang_en = require('./lang/us.json')
6
-
7 4
 const APP_URL = process.env.APP_URL
8 5
 
9 6
 module.exports = {
@@ -36,9 +33,9 @@ module.exports = {
36 33
     { src: '~/assets/style/app.styl', lang: 'styl'}
37 34
   ],
38 35
 
39
-  // serverMiddleware: [
40
-  //   '@/middleware/redirect-to-non-www.js'
41
-  // ],
36
+  serverMiddleware: [
37
+    '@/middleware/redirect-to-non-www.js'
38
+  ],
42 39
 
43 40
   /*
44 41
   ** Plugins to load before mounting the App

Loading…
Cancel
Save