Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions client/packages/cli/src/lib/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,26 @@ export const getDashUrl = Effect.gen(function* () {
const setEnv = yield* Config.string('INSTANT_CLI_DASH_URI').pipe(
Config.option,
);
const dev = Option.getOrNull(
yield* Config.boolean('INSTANT_CLI_DEV').pipe(Config.option),
const dev = yield* Config.boolean('INSTANT_CLI_DEV').pipe(
Config.withDefault(false),
);

return Option.match(setEnv, {
onSome: (url) => url,
onNone: () => (dev ? 'http://localhost:3000' : 'https://instantdb.com'),
});
if (Option.isSome(setEnv)) {
return setEnv.value;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

const instantConfig = yield* Effect.tryPromise(readInstantConfigFile);
if (instantConfig?.dashURI !== undefined) {
yield* Schema.decodeUnknown(HttpUrl)(instantConfig.dashURI).pipe(
Effect.mapError(() =>
BadArgsError.make({
message:
'Invalid dashURI in instant.config.ts. Expected a valid HTTP(S) URL.',
}),
),
);
return instantConfig.dashURI;
}

return dev ? 'http://localhost:3000' : 'https://instantdb.com';
});
1 change: 1 addition & 0 deletions client/packages/cli/src/util/instantConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { loadConfig } from './loadConfig.ts';

export type InstantConfig = {
apiURI?: string;
dashURI?: string;
apps?: Record<string, { id: string }>;
};

Expand Down
2 changes: 1 addition & 1 deletion client/packages/version/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// Update the version here and merge your code to main to
// publish a new version of all of the packages to npm.

const version = 'v1.0.55';
const version = 'v1.0.56';

export { version };
13 changes: 9 additions & 4 deletions client/www/app/docs/self-hosting/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,22 +170,27 @@ docker compose logs server -n 50

### Using the self-hosted instance with instant-cli

To use the Instant CLI with your local backend, you can set the `INSTANT_CLI_API_URI` environment variable to `http://localhost:8888`. For example:
To use the Instant CLI with your self-hosted instance, set `INSTANT_CLI_API_URI` to the backend URL and `INSTANT_CLI_DASH_URI` to the dashboard URL. For example:

```shell {% showCopy=true %}
# Local Machine Deployment
INSTANT_CLI_API_URI=http://localhost:8888 npx instant-cli@latest init
INSTANT_CLI_API_URI=http://localhost:8888 \
INSTANT_CLI_DASH_URI=http://localhost:3000 \
npx instant-cli@latest init

# Server Deployment
INSTANT_CLI_API_URI=https://api.myinstant.com npx instant-cli@latest init
INSTANT_CLI_API_URI=https://api.myinstant.com \
INSTANT_CLI_DASH_URI=https://dash.myinstant.com \
npx instant-cli@latest init
```
Comment thread
coderabbitai[bot] marked this conversation as resolved.

You can also set it in the `instant.config.ts` file.
You can also set both URLs in the `instant.config.ts` file.

```typescript
// instant.config.ts
export default {
apiURI: 'http://127.0.0.1:8888',
dashURI: 'http://localhost:3000',
};
```

Expand Down
Loading