Next.js Discord

Discord Forum

Dynamic Shop - accessing path (request) on ServerComponent

Unanswered
English Lop posted this in #help-forum
Open in Discord
English LopOP
Hey guys 🙂

I'm working with next 13 and currently i'm trying to implement a dynamically fetching server component. this is my case:
there are 2 scenarios. i'm accessing the app/page.js direct via a domain (test.com) or via a dynamic subdomain (hello.test.com) now i want to fetch the content of my onlineshop. and therefore i need to know which onlineshop should be "opened". the subdomain is the username or the apex domain. (apex domain is safed in the db in relation to my users) now i need to pass {value: "hello", type: "subdomain"} or {value: 'test.com', type: 'domain'} to my backend to get the right content back. but how can i access this data because it's not rendered in the client 🙂

sry for the noob question but i can access headers and cookies but not the request itself. maybe im missing something.
thank you
Adam

1 Reply

you can forward the data in the request to the header in the middleware