terraria-latest-version-api

node v10.24.1
version: 1.0.3
endpointsharetweet
const url = require('url') const { send } = require('micro') const axios = require('axios') const xpath = require('xpath-html'); const terrariaUrl = 'https://terraria.org/api/get/dedicated-servers-names' exports.endpoint = async function (req, res) { try { const redirect = new URL(req.url, 'https://localhost/').searchParams.get('dl') const [desktop, mobile] = await axios(terrariaUrl).then(res => res.data) const dlUrl = `https://terraria.org/api/download/pc-dedicated-server/${desktop}` if (redirect == '1') { res.setHeader('Location', dlUrl) send(res, 307) } else { send(res, 200, dlUrl) } } catch (e) { console.log(e) send(res, 500, 'Internal Server Error') } }
Loading…

no comments

    sign in to comment