Switch link expansion method
This commit is contained in:
parent
2574e5a828
commit
f39464ad8c
@ -1,9 +1,11 @@
|
|||||||
import { tall } from 'tall';
|
const fetch = require('node-fetch');
|
||||||
|
|
||||||
|
|
||||||
export default function (context) {
|
export default function (context) {
|
||||||
return tall(process.env.SHORTENER_BASE+context.route.path).then(function(unshortenedUrl) {
|
return fetch(process.env.SHORTENER_BASE+context.route.path, {
|
||||||
if(unshortenedUrl == process.env.SHORTENER_BASE) {
|
redirect: 'manual',
|
||||||
|
}).then(function(res) {
|
||||||
|
var unshortenedUrl = res.headers.get('Location');
|
||||||
|
if(unshortenedUrl == process.env.SHORTENER_BASE+"/") {
|
||||||
context.error({ statusCode: 404, message: "The page cannot be found"});
|
context.error({ statusCode: 404, message: "The page cannot be found"});
|
||||||
} else {
|
} else {
|
||||||
context.redirect(unshortenedUrl);
|
context.redirect(unshortenedUrl);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
"cross-env": "^5.2.0",
|
"cross-env": "^5.2.0",
|
||||||
"express": "^4.16.4",
|
"express": "^4.16.4",
|
||||||
"howler": "^2.1.2",
|
"howler": "^2.1.2",
|
||||||
|
"node-fetch": "^2.6.0",
|
||||||
"node-sass": "^4.12.0",
|
"node-sass": "^4.12.0",
|
||||||
"nuxt": "^2.0.0",
|
"nuxt": "^2.0.0",
|
||||||
"sass-loader": "^8.0.0",
|
"sass-loader": "^8.0.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user