I’m starting lemmy-ui with:

LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy-alpha:8541 node dist/js/server.js

Running against the drone-lemmy instances created by lemmy_server’s api-tests scripts. I’m running latest main checkout on both projects.

My browser gives me:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8536/api/v3/community/list?type_=Local&sort=TopMonth&limit=50&page=1. (Reason: CORS request did not succeed). Status code: (null).

api-tests scripts build dev mode, I thought CORS was turned off? I’ve played around with adding LEMMY_CORS_ORIGIN=* - but it doesn’t help.

EDIT: reading this post closer, I see 8536 vs. 8541. If I manually refresh my browser against lemmy-ui on port 1234, it works… but I wonder where 8536 is getting picked up?

Thank you and I hope you are having a great weekend.

  • RoundSparrowOP
    link
    fedilink
    arrow-up
    3
    ·
    1 year ago

    OK, solved my own issue

    lemmy-ui bypasses the variable if it sees you running localhost 1234, it hard codes 8536

    export default function getExternalHost() {
      return isBrowser()
        ? `${window.location.hostname}${
            ["1234", "1235"].includes(window.location.port)
              ? ":8536"
              : window.location.port === ""
              ? ""
              : `:${window.location.port}`
          }`
        : process.env.LEMMY_UI_LEMMY_EXTERNAL_HOST || testHost;
    }