Merge pull request #1688 from SkynetLabs/clean-up-dashboard-url-env-var

remove dashboard url env var usage
This commit is contained in:
Karol Wypchło 2022-02-15 10:53:30 +01:00 committed by GitHub
commit f2846146f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 15 additions and 14 deletions

View File

@ -67,7 +67,7 @@ services:
- .env
environment:
- 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}
volumes:
- ./docker/data/dashboard/.next:/usr/app/.next

View File

@ -18,7 +18,7 @@ export default async function billingApi(req, res) {
const customer = await getStripeCustomer(stripeCustomerId);
const session = await stripe.billingPortal.sessions.create({
customer: customer.id,
return_url: `${process.env.SKYNET_DASHBOARD_URL}/payments`,
return_url: `https://account.${process.env.PORTAL_DOMAIN}/payments`,
});
res.redirect(session.url);

View File

@ -47,8 +47,8 @@ export default async function checkoutApi(req, res) {
customer: customer.id,
client_reference_id: user.sub,
allow_promotion_codes: true,
success_url: `${process.env.SKYNET_DASHBOARD_URL}/payments?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${process.env.SKYNET_DASHBOARD_URL}/payments`,
success_url: `https://account.${process.env.PORTAL_DOMAIN}/payments?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `https://account.${process.env.PORTAL_DOMAIN}/payments`,
});
res.json({ sessionId: session.id });

View File

@ -1,5 +1,5 @@
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` });

View File

@ -2,7 +2,7 @@ import useSWR from "swr";
import { useRouter } from "next/router";
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) => {
return fetch(url).then((res) => {

View File

@ -2,7 +2,8 @@ import useSWR from "swr";
import { useRouter } from "next/router";
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) => {
return fetch(url).then((res) => {
if (res.status === StatusCodes.OK) router.push("/");

View File

@ -99,7 +99,7 @@ async function websiteSkylinkCheck(done) {
// accountWebsiteCheck returns the result of accessing account dashboard website
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));
}
@ -160,7 +160,7 @@ async function accountHealthCheck(done) {
const data = { up: false };
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.response = response.body;

View File

@ -4,10 +4,11 @@ if (!process.env.SKYNET_PORTAL_API) {
throw new Error("You need to provide SKYNET_PORTAL_API environment variable");
}
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 (!process.env.PORTAL_DOMAIN) {
throw new Error("You need to provide PORTAL_DOMAIN environment variable");
}
if (process.env.ACCOUNTS_ENABLED === "true") {
if (["authenticated", "subscription"].includes(process.env.ACCOUNTS_LIMIT_ACCESS)) {
if (!process.env.ACCOUNTS_TEST_USER_EMAIL) {
throw new Error("ACCOUNTS_TEST_USER_EMAIL cannot be empty");

View File

@ -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
# * 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_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
# * 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)
@ -45,7 +44,7 @@ docker-compose --version # sanity check
# * COOKIE_ENC_KEY - (optional) if using `accounts` encryption key, at least 32 bytes
if ! [ -f /home/user/skynet-webportal/.env ]; then
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
# Start docker container with nginx and client