a year ago
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:
```cause: Error: getaddrinfo ENOTFOUND directus.railway.internal
12 50.12 at GetAddrInfoReqWrap.onlookup as oncomplete
12 50.12 at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
12 50.12 errno: -3008,
12 50.12 code: 'ENOTFOUND',
12 50.12 syscall: 'getaddrinfo',
12 50.12 hostname: 'directus.railway.internal'
12 50.12 },
12 50.12 digest: '2095498725'
12 50.12 }```
This is the variable I am using for the route: DIRECTUS_HOST_URL=http://${{directus.RAILWAY_PRIVATE_DOMAIN}}:${{directus.PORT}}
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.
0 Replies
a year ago
So, what happens in my template is that Directus <-> DB uses private networking
a year ago
In your case you are trying to do NextJs <-> Directus
a year ago
And Directus is basically your API so it can't be in the private networking
a year ago
Unless you are doing NextJs <-> API <-> Directus, this way you can make the connection between your API and Directus private
a year ago
'cause how would your user be able to access it?
a year ago
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?
a year ago
So now u just hit a grey area <:kekw:788259314607325204>
I thought about that, but I don't know how it works, I don't use NextJs or its server features
a year ago
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.
a year ago
Np, sorry that I couldn't really help you
a year ago
these two docs sections may provide more information
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
a year ago
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.
a year ago
what errors are you getting
```cause: Error: getaddrinfo ENOTFOUND directus.railway.internal
12 50.12 at GetAddrInfoReqWrap.onlookup as oncomplete
12 50.12 at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
12 50.12 errno: -3008,
12 50.12 code: 'ENOTFOUND',
12 50.12 syscall: 'getaddrinfo',
12 50.12 hostname: 'directus.railway.internal'
12 50.12 },
12 50.12 digest: '2095498725'
12 50.12 }
12 50.12
12 50.12 Error occurred prerendering page "/articles". Read more: https://nextjs.org/docs/messages/prerender-error
12 50.12
12 50.12 TypeError: fetch failed
12 50.12 at Object.fetch (node:internal/deps/undici/undici:11372:11)
12 50.12 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
12 50.12 at async Object.request (/app/.next/server/chunks/330.js:15:33663)
12 50.12 at async l (/app/.next/server/app/articles/page.js:1:2892)
12 50.14
12 50.14 > Export encountered errors on following paths:
12 50.14 /articles/page: /articles
```
a year ago
can you show me a screenshot of your railway project?
a year ago
did you deploy directus yourself?
yes, { "name": "directus", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "start": "npx directus start" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "directus": "^10.10.5", "pg": "^8.11.5" } }
this is the package.json for it,
a year ago
thats very far from ideal
a year ago
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
a year ago
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.
a year ago
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
a year ago
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
a year ago
and even if you didn't care about egress fees, there's still that extra round trip time from contacting external services
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
a year ago
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.
a year ago
gotcha
a year ago
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!
a year ago
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