Skip to content

Commit 77bfa64

Browse files
authored
Merge pull request #10 from eungyeole/develop
Develop
2 parents 31290e3 + 2431eb6 commit 77bfa64

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

api/redirect.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)