remove dashboard url env var usage
This commit is contained in:
parent
4b574b33a2
commit
563e351f8e
|
@ -67,7 +67,7 @@ services:
|
||||||
- .env
|
- .env
|
||||||
environment:
|
environment:
|
||||||
- NEXT_PUBLIC_SKYNET_PORTAL_API=${SKYNET_PORTAL_API}
|
- NEXT_PUBLIC_SKYNET_PORTAL_API=${SKYNET_PORTAL_API}
|
||||||
- NEXT_PUBLIC_SKYNET_DASHBOARD_URL=${SKYNET_DASHBOARD_URL}
|
- NEXT_PUBLIC_PORTAL_DOMAIN=${PORTAL_DOMAIN}
|
||||||
- NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=${STRIPE_PUBLISHABLE_KEY}
|
- NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=${STRIPE_PUBLISHABLE_KEY}
|
||||||
volumes:
|
volumes:
|
||||||
- ./docker/data/dashboard/.next:/usr/app/.next
|
- ./docker/data/dashboard/.next:/usr/app/.next
|
||||||
|
|
|
@ -18,7 +18,7 @@ export default async function billingApi(req, res) {
|
||||||
const customer = await getStripeCustomer(stripeCustomerId);
|
const customer = await getStripeCustomer(stripeCustomerId);
|
||||||
const session = await stripe.billingPortal.sessions.create({
|
const session = await stripe.billingPortal.sessions.create({
|
||||||
customer: customer.id,
|
customer: customer.id,
|
||||||
return_url: `${process.env.SKYNET_DASHBOARD_URL}/payments`,
|
return_url: `https://account.${process.env.PORTAL_DOMAIN}/payments`,
|
||||||
});
|
});
|
||||||
|
|
||||||
res.redirect(session.url);
|
res.redirect(session.url);
|
||||||
|
|
|
@ -47,8 +47,8 @@ export default async function checkoutApi(req, res) {
|
||||||
customer: customer.id,
|
customer: customer.id,
|
||||||
client_reference_id: user.sub,
|
client_reference_id: user.sub,
|
||||||
allow_promotion_codes: true,
|
allow_promotion_codes: true,
|
||||||
success_url: `${process.env.SKYNET_DASHBOARD_URL}/payments?session_id={CHECKOUT_SESSION_ID}`,
|
success_url: `https://account.${process.env.PORTAL_DOMAIN}/payments?session_id={CHECKOUT_SESSION_ID}`,
|
||||||
cancel_url: `${process.env.SKYNET_DASHBOARD_URL}/payments`,
|
cancel_url: `https://account.${process.env.PORTAL_DOMAIN}/payments`,
|
||||||
});
|
});
|
||||||
|
|
||||||
res.json({ sessionId: session.id });
|
res.json({ sessionId: session.id });
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import ky from "ky";
|
import ky from "ky";
|
||||||
|
|
||||||
const prefix = process.env.NEXT_PUBLIC_SKYNET_DASHBOARD_URL ?? "";
|
const prefix = process.env.NEXT_PUBLIC_PORTAL_DOMAIN ? `https://account.${process.env.NEXT_PUBLIC_PORTAL_DOMAIN}` : "";
|
||||||
|
|
||||||
export default ky.create({ prefixUrl: `${prefix}/api` });
|
export default ky.create({ prefixUrl: `${prefix}/api` });
|
||||||
|
|
|
@ -2,7 +2,7 @@ import useSWR from "swr";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { StatusCodes } from "http-status-codes";
|
import { StatusCodes } from "http-status-codes";
|
||||||
|
|
||||||
const prefix = process.env.NEXT_PUBLIC_SKYNET_DASHBOARD_URL ?? "";
|
const prefix = process.env.NEXT_PUBLIC_PORTAL_DOMAIN ? `https://account.${process.env.NEXT_PUBLIC_PORTAL_DOMAIN}` : "";
|
||||||
|
|
||||||
const fetcher = (url, router) => {
|
const fetcher = (url, router) => {
|
||||||
return fetch(url).then((res) => {
|
return fetch(url).then((res) => {
|
||||||
|
|
|
@ -2,7 +2,8 @@ import useSWR from "swr";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { StatusCodes } from "http-status-codes";
|
import { StatusCodes } from "http-status-codes";
|
||||||
|
|
||||||
const prefix = process.env.NEXT_PUBLIC_SKYNET_DASHBOARD_URL ?? "";
|
const prefix = process.env.NEXT_PUBLIC_PORTAL_DOMAIN ? `https://account.${process.env.NEXT_PUBLIC_PORTAL_DOMAIN}` : "";
|
||||||
|
|
||||||
const fetcher = (url, router) => {
|
const fetcher = (url, router) => {
|
||||||
return fetch(url).then((res) => {
|
return fetch(url).then((res) => {
|
||||||
if (res.status === StatusCodes.OK) router.push("/");
|
if (res.status === StatusCodes.OK) router.push("/");
|
||||||
|
|
|
@ -99,7 +99,7 @@ async function websiteSkylinkCheck(done) {
|
||||||
|
|
||||||
// accountWebsiteCheck returns the result of accessing account dashboard website
|
// accountWebsiteCheck returns the result of accessing account dashboard website
|
||||||
async function accountWebsiteCheck(done) {
|
async function accountWebsiteCheck(done) {
|
||||||
const url = `${process.env.SKYNET_DASHBOARD_URL}/auth/login`;
|
const url = `https://account.${process.env.PORTAL_DOMAIN}/auth/login`;
|
||||||
|
|
||||||
return done(await genericAccessCheck("account_website", url));
|
return done(await genericAccessCheck("account_website", url));
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ async function accountHealthCheck(done) {
|
||||||
const data = { up: false };
|
const data = { up: false };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await got(`${process.env.SKYNET_DASHBOARD_URL}/health`, { responseType: "json" });
|
const response = await got(`https://account.${process.env.PORTAL_DOMAIN}/health`, { responseType: "json" });
|
||||||
|
|
||||||
data.statusCode = response.statusCode;
|
data.statusCode = response.statusCode;
|
||||||
data.response = response.body;
|
data.response = response.body;
|
||||||
|
|
|
@ -4,10 +4,11 @@ if (!process.env.SKYNET_PORTAL_API) {
|
||||||
throw new Error("You need to provide SKYNET_PORTAL_API environment variable");
|
throw new Error("You need to provide SKYNET_PORTAL_API environment variable");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!process.env.PORTAL_DOMAIN) {
|
||||||
|
throw new Error("You need to provide PORTAL_DOMAIN environment variable");
|
||||||
|
}
|
||||||
|
|
||||||
if (process.env.ACCOUNTS_ENABLED === "true") {
|
if (process.env.ACCOUNTS_ENABLED === "true") {
|
||||||
if (!process.env.SKYNET_DASHBOARD_URL) {
|
|
||||||
throw new Error("You need to provide SKYNET_DASHBOARD_URL environment variable when accounts are enabled");
|
|
||||||
}
|
|
||||||
if (["authenticated", "subscription"].includes(process.env.ACCOUNTS_LIMIT_ACCESS)) {
|
if (["authenticated", "subscription"].includes(process.env.ACCOUNTS_LIMIT_ACCESS)) {
|
||||||
if (!process.env.ACCOUNTS_TEST_USER_EMAIL) {
|
if (!process.env.ACCOUNTS_TEST_USER_EMAIL) {
|
||||||
throw new Error("ACCOUNTS_TEST_USER_EMAIL cannot be empty");
|
throw new Error("ACCOUNTS_TEST_USER_EMAIL cannot be empty");
|
||||||
|
|
|
@ -67,7 +67,7 @@ function getAuthCookie() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// authenticate with given test user credentials
|
// authenticate with given test user credentials
|
||||||
const response = await got.post(`${process.env.SKYNET_DASHBOARD_URL}/api/login`, {
|
const response = await got.post(`https://account.${process.env.PORTAL_DOMAIN}/api/login`, {
|
||||||
json: { email, password },
|
json: { email, password },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ function getAuthCookie() {
|
||||||
// 401 means that service worked but user could not have been authenticated
|
// 401 means that service worked but user could not have been authenticated
|
||||||
if (error.response && error.response.statusCode === 401) {
|
if (error.response && error.response.statusCode === 401) {
|
||||||
// sign up with the given credentials
|
// sign up with the given credentials
|
||||||
await got.post(`${process.env.SKYNET_DASHBOARD_URL}/api/user`, {
|
await got.post(`https://account.${process.env.PORTAL_DOMAIN}/api/user`, {
|
||||||
json: { email, password },
|
json: { email, password },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ docker-compose --version # sanity check
|
||||||
# * SERVER_DOMAIN - (optional) is an optional direct server domain (ex. eu-ger-1.siasky.net) - leave blank unless it is different than PORTAL_DOMAIN
|
# * SERVER_DOMAIN - (optional) is an optional direct server domain (ex. eu-ger-1.siasky.net) - leave blank unless it is different than PORTAL_DOMAIN
|
||||||
# * SKYNET_PORTAL_API - absolute url to the portal api ie. https://siasky.net (general portal address)
|
# * SKYNET_PORTAL_API - absolute url to the portal api ie. https://siasky.net (general portal address)
|
||||||
# * SKYNET_SERVER_API - absolute url to the server api ie. https://eu-ger-1.siasky.net (direct server address, if this is single server portal use the same address as SKYNET_PORTAL_API)
|
# * SKYNET_SERVER_API - absolute url to the server api ie. https://eu-ger-1.siasky.net (direct server address, if this is single server portal use the same address as SKYNET_PORTAL_API)
|
||||||
# * SKYNET_DASHBOARD_URL - (optional) absolute url to the portal dashboard ie. https://account.siasky.net
|
|
||||||
# * EMAIL_ADDRESS - this is the administrator contact email you need to supply for communication regarding SSL certification
|
# * EMAIL_ADDRESS - this is the administrator contact email you need to supply for communication regarding SSL certification
|
||||||
# * HSD_API_KEY - this is auto generated secure key for your handshake service integration
|
# * HSD_API_KEY - this is auto generated secure key for your handshake service integration
|
||||||
# * CLOUDFLARE_AUTH_TOKEN - (optional) if using cloudflare as dns loadbalancer (need to change it in Caddyfile too)
|
# * CLOUDFLARE_AUTH_TOKEN - (optional) if using cloudflare as dns loadbalancer (need to change it in Caddyfile too)
|
||||||
|
@ -45,7 +44,7 @@ docker-compose --version # sanity check
|
||||||
# * COOKIE_ENC_KEY - (optional) if using `accounts` encryption key, at least 32 bytes
|
# * COOKIE_ENC_KEY - (optional) if using `accounts` encryption key, at least 32 bytes
|
||||||
if ! [ -f /home/user/skynet-webportal/.env ]; then
|
if ! [ -f /home/user/skynet-webportal/.env ]; then
|
||||||
HSD_API_KEY=$(openssl rand -base64 32) # generate safe random key for handshake
|
HSD_API_KEY=$(openssl rand -base64 32) # generate safe random key for handshake
|
||||||
printf "PORTAL_DOMAIN=siasky.net\nSERVER_DOMAIN=\nSKYNET_PORTAL_API=https://siasky.net\nSKYNET_SERVER_API=https://eu-dc-1.siasky.net\nSKYNET_DASHBOARD_URL=https://account.example.com\nEMAIL_ADDRESS=email@example.com\nSIA_WALLET_PASSWORD=\nHSD_API_KEY=${HSD_API_KEY}\nCLOUDFLARE_AUTH_TOKEN=\nAWS_ACCESS_KEY_ID=\nAWS_SECRET_ACCESS_KEY=\nPORTAL_NAME=\DISCORD_WEBHOOK_URL=\nDISCORD_MENTION_USER_ID=\nDISCORD_MENTION_ROLE_ID=\n" > /home/user/skynet-webportal/.env
|
printf "PORTAL_DOMAIN=siasky.net\nSERVER_DOMAIN=\nSKYNET_PORTAL_API=https://siasky.net\nSKYNET_SERVER_API=https://eu-dc-1.siasky.net\nEMAIL_ADDRESS=email@example.com\nSIA_WALLET_PASSWORD=\nHSD_API_KEY=${HSD_API_KEY}\nCLOUDFLARE_AUTH_TOKEN=\nAWS_ACCESS_KEY_ID=\nAWS_SECRET_ACCESS_KEY=\nPORTAL_NAME=\DISCORD_WEBHOOK_URL=\nDISCORD_MENTION_USER_ID=\nDISCORD_MENTION_ROLE_ID=\n" > /home/user/skynet-webportal/.env
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start docker container with nginx and client
|
# Start docker container with nginx and client
|
||||||
|
|
Reference in New Issue