Hi, I've had a couple of issues with data not seeming to be consistent via the Local Api but can't rule out I'm going crazy through overwork 😉
I could have sworn this morning I was receiving the full url from Payload to my next.js app (both on the same server but with different sub-domains). But when I moved from my laptop to my desktop before (and restarted yarn dev on payload and npm dev on my next.js app) the images stopped showing and I had to add a BASE_URL to my code to add the domain to make them display...?!
Given I've had a couple of "wtfs?" over issues like this, I'm just a bit concerned that either I'm doing something wrong that is evading me, or something is unstable. If I had to bet, I'd put the blame on me but either way it'd be great to understand why this may be happening if anyone knows?
ps. this is media objects inside post objects.
Did you cross-reference .env files as well as verify any local in-progress changes?
Unfortunately, this is not quite enough information to pinpoint anything.
thanks. my .env files (in both my payload app and my main next.js frontend app) haven't changed for days. I was working on my laptop - using a remote ssh connection to a server in vscode - for a few hours, all fine. I went to my desktop and carried on there - also in vscode, same project, same connection to the same server - and the images stopped displaying. That's when I noticed the returned data didn't have the full url, just the path.
I had to add a BASE_IMG_URL prefix to them in all components so they would display - so that suggests I'm correct that they were being sent with the full URLs all week that I've been using payload, otherwise they would never have displayed (unless there's something else I just cant't think of...?)
What's the default - should urls for Media items come with the full path including domain? Is there any setting or cirmcumstance that would stop that happening?
URLs will be full path including domain. Can you post your media collection config?
Sorry, I've been travelling and just had a chance to look at this again. I'm using this method -https://discord.com/channels/967097582721572934/1138020824520069150
- to use a local installation of Payload CMS on the same server as my next.js app - but not part of the same project.
I found the problem tonight. In my next.js .env file I was missing PAYLOAD_PUBLIC_SERVER_URL=....
Now I set that correctly to the URL of the Payload instance, it works fine.
What confuses me though is it was working at first, then it stopped working - BUT... in my vscode timeline for the .env file, I've never had the setting there...?!
Still - working now. Thanks for your help in letting me know it should do what it's now doing, it helped me find my error. Thanks!