dubinc / dub

Open-source link management infrastructure. Loved by modern marketing teams like Vercel, Raycast, and Perplexity.
https://dub.co
GNU Affero General Public License v3.0
18.9k stars 2.04k forks source link

[FEAT]: Redirect rule #529

Open steven-tey opened 10 months ago

steven-tey commented 10 months ago

Ability to define a redirect rule for a given route pattern instead of manually defining all the links.

E.g. doma.in/:path → domain.com/products/:path

Use case: ShareGPThttps://shareg.pt/bPdEf2F redirects to https://sharegpt.com/c/bPdEf2F

linear[bot] commented 10 months ago

ENG-131 [FEAT]: Redirect rule

hemant-code625 commented 10 months ago

Hi steven! Can we leverage the redirects configuration in next.config.js?

module.exports = { async redirects() { return [ { source: '/doma.in/:path', // Match any path starting with '/doma.in/' destination: 'https://domain.com/products/:path', // Preserve the original path permanent: false, // Optional: Set to true for a permanent (308) redirect }, ]; }, };

steven-tey commented 10 months ago

Hi @hemant-code625! That won't be possible in our case since we're using edge middleware to handle redirects. We'll also have to rethink our existing redirect logic (GETa kv-pair from Redis and redirect if exists) and adapt that to this use case.

hemant-code625 commented 10 months ago

Thank you @steven-tey for clarifying. Let me learn about this edge middleware and our codebase, I'll be back to resolve this issue soon.

steven-tey commented 8 months ago

Some ideas:

lessthomas commented 6 months ago

@steven-tey as we talked about via email, I'm sharing my input here.

We would love wildcards in links - for instance domain/introduction-deck/* - for which we could input anything, e.g. introduction-deck/clientA, introduction-deck/clientB. It would always redirect to the parent link /introduction-deck but track each child link (the wildcard). This makes it much faster for our sales team to share material without needing to create new links.

For analytics, initially a simple table view would be fine. A more advanced solution would be two analytics pages: 1) parent links and 2) child links which required a selection of a parent through a dropdown or similar. The advanced solution might not be feasible with the overall product direction, so a REST API to extract data would also be just fine (i.e. GET call with date params to get all links with analytics per day - we can parse the rest).

steven-tey commented 6 months ago

Appreciate the input here @lessthomas 🙏