how get the originalUrl (the incoming HTTP request from Node core) #2632
Unanswered
guoxiangke
asked this question in
Q&A
Replies: 1 comment
-
I am not sure if I understand what your are asking import { Hono } from 'hono';
app.get('/', async (c) => {
const path = c.req.url;
return c.text(path);
});
export default app; And when I go to The result I get is the exact same as entered. If I want to redirect it to the entered url this works just fine app.get('/', async (c) => {
const path = c.req.query('redirect');
if (!path) {
return c.json({ success: false });
}
return c.redirect(path);
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I build a redirect app with honojs.
I need the origin raw incoming url, how to get it in c.req.url?
I found the : https://fastify.dev/docs/latest/Reference/Request/ has a raw method.
does honojs has one like that? thanks.
raw - the incoming HTTP request from Node core
url - the URL of the incoming request
originalUrl - similar to url, this allows you to access the original url in case of internal re-routing
the reason why I want is that:
I want
http://localhost:3000/api?redirect=http://napi.yageapp.com/api/t.php?k=6b42e8370481f752?metric=NFC%26keyword=nav%26target=%E7%9B%9F%E7%BA%A6%E8%AF%97%E6%AD%8C
redirect to
http://napi.yageapp.com/api/t.php?k=6b42e8370481f752
YES! there are more than 1 ?
Beta Was this translation helpful? Give feedback.
All reactions