#local demo in Windows

15 messages · Page 1 of 1 (latest)

peak lion
#

I am trying to run the demo under windows. The cms is working fine.

for the site I tried .env
NEXT_PUBLIC_CMS_URL=http://localhost:3000

NEXT_PUBLIC_CLOUD_CMS_URL=http://localhost:8001

NEXT_PUBLIC_SITE_URL=http://local.payloadcms.com:3001

when I try to bring up the site http://local.payloadcms.com:3001/

Error: Unexpected token < in JSON at position 0

Source
src\graphql\index.ts (30:19) @ async fetchGlobals

28 | templates: Template[]
29 | }> => {

30 | const { data } = await fetch(${process.env.NEXT_PUBLIC_CMS_URL}/api/graphql?globals, {
| ^
31 | method: 'POST',
32 | headers: {
33 | 'Content-Type': 'application/json',
Call Stack
async RootLayout
src\app\layout.tsx (16:42)

humble patrol
#

Doesn't that fetch url need to be wrapped in back ticks because its uses a template literal?

#

`${myurl}.com`

#

maybe not, im bad with jsx

peak lion
#

There are backticks in the source file, they just do not show up in the error message. I think the error means the fetch returned not JSON. Likely some error in my env

native marten
#

do you have your CMS filled out? (with globals in this case)

peak lion
#

I don't know what that means. I can login to the cms at localhost:3000/admin - seems fine Please send a link

clear void
peak lion
#

I am hoping to get the payload site running locally

clear void
#

@peak lion the error appears to be looking for global data and cannot find any - try adding some dummy data in your footer / main menu in the CMS and see if the error persists

peak lion
#

I added a new post - six total. same

#

PS C:\projects\payload\website> npm run dev
npm WARN config global --global, --local are deprecated. Use --location=global instead.

payload-website@1.0.2 dev
next dev

warn - Port 3000 is in use, trying 3001 instead.
ready - started server on 0.0.0.0:3001, url: http://localhost:3001
info - Loaded env from C:\Projects\payload\website.env
warn - You have enabled experimental feature (appDir) in next.config.js.
info - Thank you for testing appDir please leave your feedback at https://nextjs.link/app-feedback
warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at packageData (C:\Projects\payload\website\node_modules\next\dist\compiled\undici\index.js:2:5022)
at specConsumeBody (C:\Projects\payload\website\node_modules\next\dist\compiled\undici\index.js:2:4734)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.module.exports [as redirects] (C:\Projects\payload\website\redirects.js:34:25)
at async loadRedirects (C:\Projects\payload\website\node_modules\next\dist\lib\load-custom-routes.js:415:21)
at async Promise.all (index 2)
at async Object.loadCustomRoutes [as default] (C:\Projects\payload\website\node_modules\next\dist\lib\load-custom-routes.js:13:44)
at async DevServer.prepareImpl (C:\Projects\payload\website\node_modules\next\dist\server\dev\next-dev-server.js:619:29)
at async NextServer.prepare (C:\Projects\payload\website\node_modules\next\dist\server\next.js:138:13)
at async Server.<anonymous> (C:\Projects\payload\website\node_modules\next\dist\server\lib\render-server.js:92:17) {
type: 'SyntaxError'
}
PS C:\projects\payload\website>

GitHub

Next.js 13 introduces the app directory (beta) with new features and conventions. However, upgrading to Next.js 13 does not require using the app directory. This discussion is where you can provide...

peak lion
#

the repo from 16 hours ago

C:\Projects\payload\site>yarn dev
yarn run v1.22.19
$ next dev
warn - Port 3000 is in use, trying 3001 instead.
ready - started server on 0.0.0.0:3001, url: http://localhost:3001
info - Loaded env from C:\Projects\payload\site.env
warn - You have enabled experimental feature (appDir) in next.config.js.
info - Thank you for testing appDir please leave your feedback at https://nextjs.link/app-feedback
warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

TypeError: Failed to parse URL from undefined/api/redirects?limit=1000&depth=1
at Object.fetch (C:\Projects\payload\site\node_modules\next\dist\compiled\undici\index.js:1:26686)
at async Object.module.exports [as redirects] (C:\Projects\payload\site\redirects.js:31:24)
at async loadRedirects (C:\Projects\payload\site\node_modules\next\dist\lib\load-custom-routes.js:415:21)
at async Promise.all (index 2)
at async Object.loadCustomRoutes [as default] (C:\Projects\payload\site\node_modules\next\dist\lib\load-custom-routes.js:13:44)
at async DevServer.prepareImpl (C:\Projects\payload\site\node_modules\next\dist\server\dev\next-dev-server.js:619:29)
at async NextServer.prepare (C:\Projects\payload\site\node_modules\next\dist\server\next.js:138:13)
at async Server.<anonymous> (C:\Projects\payload\site\node_modules\next\dist\server\lib\render-server.js:92:17) {
type: 'TypeError'
}

GitHub

Next.js 13 introduces the app directory (beta) with new features and conventions. However, upgrading to Next.js 13 does not require using the app directory. This discussion is where you can provide...