payloadcms / public-demo

The official public demo for Payload
https://demo.payloadcms.com
152 stars 74 forks source link

How to host this public-demo on vps with custom domain? #37

Open LoydAndrew opened 9 months ago

LoydAndrew commented 9 months ago

Okay, I tried different approaches with no luck. Requests from localhost next site to localhost payload are working, but from custom.localhost to custom.localhost aren't. I'm using caddy for reverse proxy in docker and tried to host payload API on subdomain API.custom.localhost but fetch will throw error on server indicating address error. If I use client side requests instead of server components requests or curl it's working either way, but I still will have issues with displaying images on custom domain: request to this url https://custom_domain/_next/image?url=https%3A%2F%2Fcustom_domain%2Fmedia%2Fexample.png&w=2048&q=75 will throw error, even though url of the media is valid and I have custom_domain in next.config

  images: {
    remotePatterns: [
      { hostname: 'localhost', protocol: 'http' },
      { hostname: 'custom_domain', protocol: 'https' },
    ],
  },

custom_domain is obviously a placeholder for my real domain. I see that next js public-demo is actually being hosted on cloudflare, so maybe that's why there is no prolblem with routing resolultions.