Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

local demo in Windows

default discord avatar
.smalltalkman2 years ago
9

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)

  • default discord avatar
    notchr2 years ago

    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

  • default discord avatar
    .smalltalkman2 years ago

    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

  • discord user avatar
    jarrod_not_jared
    2 years ago

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

  • default discord avatar
    .smalltalkman2 years ago

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

  • default discord avatar
    jessrynkar2 years ago
    @823331358025449502

    after you log into the CMS, have you added some content? i.e. created a page, added a link to the main menu. (this was jarrods question)



    Also is this the demo you are running?

    https://github.com/payloadcms/next-payload-demo
  • default discord avatar
    .smalltalkman2 years ago

    I am using the web-site and cms from

    https://github.com/payloadcms/website-cms

    there are some pages



    I am hoping to get the payload site running locally

  • default discord avatar
    jessrynkar2 years ago
    @823331358025449502

    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

  • default discord avatar
    .smalltalkman2 years ago

    I added a new post - six total. same



    website 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

    NEXT_PUBLIC_GITHUB_REDIRECT_URI=

    http://local.payloadcms.com:3001/gh

    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>



    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'


    }

  • default discord avatar
    jessrynkar2 years ago

    Hey

    @823331358025449502

    - here are the steps to spin up the website! hope this helps.



    Also for this error:

    warn - Port 3000 is in use,

    this usually means to me that I have the terminal running somewhere else and forgot to close it

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.