3
submitted 1 year ago* (last edited 1 year ago) by RoundSparrow@lemmy.ml to c/lemmydev@lemm.ee

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.

top 1 comments
sorted by: hot top controversial new old
[-] RoundSparrow@lemmy.ml 3 points 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;
}

this post was submitted on 12 Aug 2023
3 points (100.0% liked)

Lemmy App Development

711 readers
1 users here now

A place for Lemmy builders to chat about building apps, clients, tools and bots for the Lemmy platform.

On-Topic:

Off-Topic:

founded 1 year ago
MODERATORS