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) {
|
||||
return tall(process.env.SHORTENER_BASE+context.route.path).then(function(unshortenedUrl) {
|
||||
if(unshortenedUrl == process.env.SHORTENER_BASE) {
|
||||
return fetch(process.env.SHORTENER_BASE+context.route.path, {
|
||||
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"});
|
||||
} else {
|
||||
context.redirect(unshortenedUrl);
|
||||
|
@ -15,6 +15,7 @@
|
||||
"cross-env": "^5.2.0",
|
||||
"express": "^4.16.4",
|
||||
"howler": "^2.1.2",
|
||||
"node-fetch": "^2.6.0",
|
||||
"node-sass": "^4.12.0",
|
||||
"nuxt": "^2.0.0",
|
||||
"sass-loader": "^8.0.0",
|
||||
|
Loading…
Reference in New Issue
Block a user