sim icon indicating copy to clipboard operation
sim copied to clipboard

How to run on host other than localhost

Open umutbesler opened this issue 8 months ago • 3 comments

Hello,

I'm trying to test the application but my docker host is remote. I've set the env file and connect successfully to the software but i couldn't authenticate because of the erro below:

`sim:dev: 2025-05-12T14:02:18.443Z ERROR [Better Auth]: Invalid origin: http://123.123.123.123:3000

sim:dev: 2025-05-12T14:02:18.444Z INFO [Better Auth]: If it's a valid URL, please add http://123.123.123.123:3000 to trustedOrigins in your auth config

sim:dev: Current list of trustedOrigins: http://localhost:3000`

I couldn't find a way to add my ip address to auth config.

How can i do this?

Thank you

umutbesler avatar May 12 '25 15:05 umutbesler

@umutbesler try adding your origin to the trustedOrigin in apps/sim/lib/auth.ts like this

export const auth = betterAuth({
  database: drizzleAdapter(db, {
    provider: 'pg',
    schema,
  }),
  trustedOrigins: ['http://123.123.123.123:3000'],
  session: {
    cookieCache: {
      enabled: true,
      maxAge: 24 * 60 * 60, // 24 hours in seconds
    },

waleedlatif1 avatar May 12 '25 19:05 waleedlatif1

Hello,

Thank you the issue is fixed and i can login the app now. But now there is another problem. Because i run this app on an ip address, the system gives the error "crypto.randomUUID is not a function".

As stated in the issue https://github.com/simstudioai/sim/issues/128#issuecomment-2769281981, we will need to configure HTTPS, but I couldn't find any information on how this system is supposed to operate over HTTPS. How can we do this?

umutbesler avatar May 15 '25 09:05 umutbesler

@umutbesler when I'm running locally, i typically run ngrok. You run npm run dev and then in a separate terminal tab, you can run ngrok http {PORT} so if you are running on port 4000, you run ngrok http 4000.

The only thing to keep in mind is that you must also change your NEXT_PUBLIC_APP_URL and BETTER_AUTH_URL to this ngrok url as well.

waleedlatif1 avatar May 15 '25 21:05 waleedlatif1

I installed simstudio on a MacBook system at 192.168.40.9 using Docker. It runs without any problems on the same system, but when I try to run it in a browser on another computer on the network, it gives the same error: TypeError: crypto.randomUUID is not a function. I made the changes mentioned in the posts above, but I still get the same error on the client side. Of course, I think I would be grateful if you could help me.

Maziar-fanaeipour avatar Aug 27 '25 17:08 Maziar-fanaeipour