Issue regarding connecting Directus and Next.js with internal routing
I am trying to connect my next.js app with Directus using internal routing. Both of them are within the same project.
I keep getting this error:
This is the variable I am using for the route:
I believe it is due to setting up Ipv6 on the directus instance. I changed the host to :: , but that does not change anything, and neither does ::0.0.0.0.
31 Replies
Project ID:
N/A
N/A
So, what happens in my template is that Directus <-> DB uses private networking
In your case you are trying to do NextJs <-> Directus
And Directus is basically your API so it can't be in the private networking
Why cannot it be in the private network?
Thank you a lot for helping out btw
Unless you are doing NextJs <-> API <-> Directus, this way you can make the connection between your API and Directus private
'cause how would your user be able to access it?
your user doesn't and cant access your services in the private network
So, my next.js will fetch the data with server functions, and then display it on the client. The user would just access the next.js site, perhaps I completely misunderstand how this is supposed to be working. But my understanding is that I would connect the next.js app with directus using nexjs server features. Wouldn't that work like connecting a backend to directus?
So now u just hit a grey area :kekw:
I thought about that, but I don't know how it works, I don't use NextJs or its server features
That would be a good question to make on the Nextjs discord server
I most probably will ask there as well. Thank you for taking the time to help me out.
Np, sorry that I couldn't really help you
No problem of course :))
these two docs sections may provide more information
https://docs.railway.app/guides/private-networking#private-network-context
https://docs.railway.app/guides/private-networking#faq
Thank you, I did already look into this although this confuses me a bit:
"A web application that makes client-side requests cannot communicate to another service over the private network."Does this mean internal routing would not work with next.js? The faq answers this, just saw that one so thank you again. But still does not solve my issue, I think it might have something to do with ipV6 with directus, I tried different solutions but none seem to be working
so you are
making the requests to directus from the server side of your nextjs app?
and
the nextjs app is in the same project?
yes, the next.js and directus are within the same project, and I am using server side to make directus requests.
what errors are you getting
can you show me a screenshot of your railway project?
Do you mean like this?
did you deploy directus yourself?
yes,
this is the package.json for it,
thats very far from ideal
please scap that and deploy medim's directus template
https://supabase.com/partners/integrations/directus
I used this to set up directus with supabase, could you tell me what is not ideal about it? Thank you a lot for taking the time to help me out btw
your directus deploys from github instead of an image, doesnt have persistent storage, doesnt dual stack bind, doesnt have a health check, is likely missing some env vars, etc etc
ok, thank you very much! I will look into the template you mentioned. I followed the tutorial to set it up with Supabase as the storage. Perhaps, I can do that with the tempalte as well.
yep you can customize the service after you deploy the template, its just better to start off with the template that is designed to run on railway in a production setting than it is to deploy it yourself
though i dont know if i can recommend using supabase for the database or storage, you would be subjecting yourself to egress fees from railway
and even if you didn't care about egress fees, there's still that extra round trip time from contacting external services
Great, that sounds quite good
keeping supabase as the database is a bit of a necessity, otherwise in case of no constraints it does make sense to keep the database within railway
may I ask why it's a necessity to use supabase?
It wasn't really my decision to do it like that, so I can't answer it properly. But one reason was that we are using supabase for other data, and we need to share it across apps although not all apps use directus.
gotcha
okay let me know when you have medim's template deployed into your project and configured to your liking, then we can pick this back up!
Wonderful, I will definitely let you know even if all goes well.
now keep in mind when you go to deploy the template into your project, you will see multiple duplicates, make sure you only deploy the one with medim's name on it, it is the only template we would be able to provide support for and we are in the process of removing all other duplicates