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.

.ENV Example file setting explanation for payload/website

default discord avatar
captken.2 years ago
15

Being a noob - I am trying to configure the repo form payload/website to run locally which builds with no issues however I can not access the admin on

http://localhost:8001/

or local.payloadcms.com:3000 - can someone give an example of the .env file that is set up for localhost please?

  • default discord avatar
    pcbal2 years ago

    Not possible an admin there. Clone repo website-cms and use port:8000 with that instance. Point payload app url as localhost:3000 for its .env and run both. Your cms at :8000 (payload/website-cms) and front end at:3000 (paylod/website) clones . For website:3000 .env add payload cms url as localhost:8000. Both run on localhost and access with desired port. It is cool no issues.

  • default discord avatar
    captken.2 years ago

    Thanks

    @1081840618944340050

    appreciate the pointers



    @1081840618944340050

    Thanks for you assistance - one more question if I may - I got managed to compile payload/website-cms which reported webpack compiled successfully and is running on

    http://localhost:8000/admin

    fine. Then I followed the directions to clone the repo for payload/website in separate folder updated .env and then yarn dev which terminal reports compiled client and server successfully then when I go to

    http://local.payloadcms.com:3000/

    i get Unhandled Runtime Error


    Error: fetch failed - Call Stack - Object.fetch -node:internal/deps/undici/undici (11413:11)- process.processTicksAndRejections - Node:internal/process/task_queues (95:5) any ideas what I should correct ?

  • default discord avatar
    pcbal2 years ago

    you cannot use local.payloadcms.com:3000 like this unless added in /etc/hosts file. Instead use simply

    http://localhost:3000
  • default discord avatar
    captken.2 years ago

    I added 127.0.0.1 local.payloadcms.com to the /etc/hosts file and have tried on both

    http://localhost:3000/

    and

    http://local.payloadcms.com:3000/

    - get the same error

  • default discord avatar
    pcbal2 years ago

    Is this the .env content.... # You can use our own CMS to build the frontend locally if you'd like,


    # Or you can change this variable to point to your own


    NEXT_PUBLIC_CMS_URL=

    http://localhost:8000

    NEXT_PUBLIC_SITE_URL=

    http://localhost:3000

    # Used to revalidate pages on Vercel


    NEXT_PRIVATE_REVALIDATION_KEY=



    # The GitHub Access Token is used to dynamically fetch Payload docs from GitHub and write them to a JSON file within this repo


    GITHUB_ACCESS_TOKEN=



    # This is not necessary unless you want to work with Algolia Docsearch


    NEXT_PUBLIC_ALGOLIA_DOCSEARCH_KEY=



    NEXT_PUBLIC_GA_MEASUREMENT_ID=


    NEXT_PUBLIC_FACEBOOK_PIXEL_ID=



    # This will allow robots to crawl your site, etc


    NEXT_PUBLIC_IS_LIVE=



    DISCORD_TOKEN=


    DISCORD_SCRAPE_CHANNEL_ID=

  • default discord avatar
    captken.2 years ago

    ok thanks will give this a try now - thanks mate



    Ok updated the .env file then yarn and yarn dev which reported that server is not running on port 8000 so I am bit lost why the server is not running ? Apologies for these noob questions Jaigo

  • default discord avatar
    pcbal2 years ago

    The fetch fails because next.js instance is failing to fetch data from cms graphQL endpoint. If everything was fine during installation it should be able to communicate with the cms. May check the .env for cms..... PORT=8000


    MONGODB_URI=mongodb://localhost/payload-website-cms


    PAYLOAD_SECRET=b669ac4d869b82184f9cc580


    PAYLOAD_PUBLIC_CMS_URL=

    http://localhost:8000

    PAYLOAD_PUBLIC_APP_URL=

    http://localhost:3000

    PAYLOAD_PRIVATE_NEXTJS_REVALIDATION_KEY=


    SENDGRID_API_KEY=



    @895705628754968577

    adjust the db name for mongo in the above .env according to your db name

  • default discord avatar
    captken.2 years ago

    ok thanks - will give this a try

  • default discord avatar
    pcbal2 years ago

    Check log... if port 8000 already taken the new instance will automatically assign to port 8001

  • default discord avatar
    captken.2 years ago

    Proving to be difficult - I dropped all the mongo DBs, deleted all the folders and started from 0 - git cloned everything and still in the same position confirming the mongo dbs are named correctly and populated - payload-website-cms> show dbs


    admin 40.00 KiB


    config 108.00 KiB


    local 40.00 KiB


    payload-website-cms 216.00 KiB



    Going to take a break - this is hurting my brain 🙏

  • default discord avatar
    pcbal2 years ago

    One possibility is the suitability of mongo version. Try using a lesser mongo version like 4.5 or so.



    @895705628754968577

    Cloud page, post saving issue is now over. You can make a new checkout.

  • default discord avatar
    captken.2 years ago

    thanks

    @1081840618944340050

    Question please: when I clone the repos for payload/website and payload/website-cms I am placing them in a parent folder "payload" and then opening this folder "payload" with VSCode - is the correct or following best use ?

  • default discord avatar
    pcbal2 years ago
    @895705628754968577

    Usually anyway you want, but better avoid using parent folder name payload. It may clash somewhere with payload import syntax since it is reserved. For example import {xxx} from payload/types may make a clash with your directory structure. Why not use something else for the folder name like projects/ or test/ etc?



    @895705628754968577

    clone repo to projects/payload/test will not make any issue.

  • discord user avatar
    patrikkozak
    2 years ago

    Hey

    @895705628754968577

    just catching up here. Let us know if

    @1081840618944340050

    's tips ended up helping. Would love to get to the bottom of this 👍

  • default discord avatar
    captken.2 years ago

    Hey

    @1032341301619871785

    thanks -

    @1081840618944340050

    has been a great help and I am having another crack at it tonight

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.