We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 31290e3 + 2431eb6 commit 77bfa64Copy full SHA for 77bfa64
api/redirect.js
@@ -0,0 +1,14 @@
1
+const fetchPost = require('../src/fetchers/post-fetcher');
2
+
3
4
+module.exports = async (req, res) => {
5
+ const { name, tag } = req.query;
6
+ try{
7
+ const post = await fetchPost(name, tag);
8
+ const url = new String(`https://velog.io/@${post.user.username}/${post.url_slug}`)
9
+ res.send(`<script>window.location.href='${url}'</script>`);
10
+ return
11
+ } catch(e){
12
+ return res.send(e.message)
13
+ }
14
+}
0 commit comments