This repository has been archived on 2021-05-27. You can view files and clone it, but cannot push or open issues or pull requests.
Files
ReRedirector/src/app.service.ts
2020-04-03 23:28:28 +08:00

26 lines
564 B
TypeScript

import axios from 'axios';
const fetchTarget = async (target: string) => {
return await axios.get(target, {
maxRedirects: 0,
validateStatus: (status) => {
return status >= 300 && status < 400;
},
});
};
export const getLocationOfTarget = async (target: string) => {
try {
const response = await fetchTarget(target);
if (response.headers.location) {
return response.headers.location as string;
}
}
catch (err) {
console.log(err);
}
return undefined;
};