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
13 changes: 8 additions & 5 deletions cli/app/commands/install/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,14 @@ def _show_success_message(self):
self.logger.info("If you have any questions, please visit the community forum at https://discord.gg/skdcq39Wpv")
self.logger.highlight("See you in the community!")

def _get_supertokens_connection_uri(self, protocol: str, api_host: str, supertokens_api_port: int):
def _get_supertokens_connection_uri(self, protocol: str, api_host: str, supertokens_api_port: int, host_ip: str):
protocol = protocol.replace("https", "http")
try:
ipaddress.ip_address(api_host)
return f"{protocol}://{api_host}"
# If api_host is an IP, use the host_ip instead, x.y.z.w:supertokens_api_port
return f"{protocol}://{host_ip}:{supertokens_api_port}"
except ValueError:
# If api_host is not IP rather domain, then use domain:supertokens_api_port
return f"{protocol}://{api_host}:{supertokens_api_port}"

def _update_environment_variables(self, env_values: dict) -> dict:
Expand All @@ -465,13 +467,14 @@ def _update_environment_variables(self, env_values: dict) -> dict:
"WEBSOCKET_URL": f"{ws_protocol}://{api_host}/ws",
"API_URL": f"{protocol}://{api_host}/api",
"WEBHOOK_URL": f"{protocol}://{api_host}/api/v1/webhook",
"NEXT_PUBLIC_API_URL": f"{protocol}://{api_host}/api",
"NEXT_PUBLIC_WEBSITE_DOMAIN": f"{protocol}://{view_host}",
"VIEW_DOMAIN": f"{protocol}://{view_host}",
"SUPERTOKENS_API_KEY": "NixopusSuperTokensAPIKey",
"SUPERTOKENS_API_DOMAIN": f"{protocol}://{api_host}/api",
"SUPERTOKENS_WEBSITE_DOMAIN": f"{protocol}://{view_host}",
# TODO: temp fix, remove this once we have a secure connection
"SUPERTOKENS_CONNECTION_URI": self._get_supertokens_connection_uri(protocol, api_host, supertokens_api_port),
"SUPERTOKENS_CONNECTION_URI": self._get_supertokens_connection_uri(
protocol, api_host, supertokens_api_port, host_ip
),
}

for key, value in key_map.items():
Expand Down
2 changes: 1 addition & 1 deletion cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nixopus"
version = "0.1.10"
version = "0.1.11"
description = "A CLI for Nixopus"
authors = ["Nixopus <raghavyuva@gmail.com>"]
readme = "README.md"
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ services:
build:
args:
- NEXT_PUBLIC_PORT=${NEXT_PUBLIC_PORT}
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
- NEXT_PUBLIC_WEBSITE_DOMAIN=${NEXT_PUBLIC_WEBSITE_DOMAIN}
ports:
- "${NEXT_PUBLIC_PORT:-7443}:${NEXT_PUBLIC_PORT:-7443}"
restart: unless-stopped
Expand Down
3 changes: 1 addition & 2 deletions helpers/config.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ services:
PORT: ${VIEW_PORT:-7443}
WEBSOCKET_URL: ${WEBSOCKET_URL:-}
API_URL: ${API_URL:-}
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-}
NEXT_PUBLIC_WEBSITE_DOMAIN: ${NEXT_PUBLIC_WEBSITE_DOMAIN:-}
VIEW_DOMAIN: ${VIEW_DOMAIN:-}
WEBHOOK_URL: ${WEBHOOK_URL:-}
NEXT_PUBLIC_PORT: ${NEXT_PUBLIC_PORT:-7443}
LOGS_PATH: ${LOGS_PATH:-./logs}
Expand Down
8 changes: 1 addition & 7 deletions view/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ COPY --from=deps /app/node_modules ./node_modules
COPY . .

ARG NEXT_PUBLIC_PORT=7443
ARG NEXT_PUBLIC_API_URL=http://localhost:8443/api
ARG NEXT_PUBLIC_WEBSITE_DOMAIN=http://localhost:7443
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=$NEXT_PUBLIC_PORT
ENV NEXT_PUBLIC_PORT=$NEXT_PUBLIC_PORT
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_WEBSITE_DOMAIN=$NEXT_PUBLIC_WEBSITE_DOMAIN

RUN yarn build && \
rm -rf node_modules/.cache
Expand All @@ -29,8 +25,6 @@ ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=$NEXT_PUBLIC_PORT
ENV NEXT_PUBLIC_PORT=$NEXT_PUBLIC_PORT
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_WEBSITE_DOMAIN=$NEXT_PUBLIC_WEBSITE_DOMAIN

RUN addgroup -S nixopus && adduser -S nixopus -G nixopus

Expand All @@ -43,4 +37,4 @@ USER nixopus

EXPOSE ${NEXT_PUBLIC_PORT}

CMD ["sh", "-c", "node server.js"]
CMD ["sh", "-c", "node server.js"]
6 changes: 5 additions & 1 deletion view/app/api/config/route.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { NextResponse } from 'next/server';

export async function GET() {
// Priority: VIEW_DOMAIN (if provided) > localhost fallback
const websiteDomain = process.env.VIEW_DOMAIN || 'http://localhost:3000';

return NextResponse.json({
baseUrl: process.env.API_URL || 'http://localhost:8080/api',
websocketUrl: process.env.WEBSOCKET_URL || 'ws://localhost:8080/ws',
webhookUrl: process.env.WEBHOOK_URL || 'http://localhost:8080/webhook',
port: process.env.NEXT_PUBLIC_PORT || '7443'
port: process.env.NEXT_PUBLIC_PORT || '7443',
websiteDomain
});
}
5 changes: 3 additions & 2 deletions view/app/config/appInfo.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { getBaseUrl } from '@/redux/conf';
import { getBaseUrl, getWebsiteDomain } from '@/redux/conf';

export const getAppInfo = async () => {
const baseUrl = await getBaseUrl();
const apiDomain = baseUrl.replace('://', 'TEMP').replace('/api', '').replace('TEMP', '://');
const websiteDomain = await getWebsiteDomain();

return {
// learn more about this on https://supertokens.com/docs/thirdpartyemailpassword/appinfo
appName: 'Nixopus',
apiDomain,
websiteDomain: process.env.NEXT_PUBLIC_WEBSITE_DOMAIN || 'http://localhost:3000',
websiteDomain,
apiBasePath: '/auth',
websiteBasePath: '/auth'
};
Expand Down
5 changes: 5 additions & 0 deletions view/redux/conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ export async function getWebhookUrl() {
const { webhookUrl } = await fetchConfig();
return webhookUrl;
}

export async function getWebsiteDomain() {
const { websiteDomain } = await fetchConfig();
return websiteDomain;
}
Loading