mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Ready for 1.1.3-rc.3 release.
This commit is contained in:
@@ -3,11 +3,11 @@ name: portabase-prod
|
|||||||
services:
|
services:
|
||||||
|
|
||||||
app:
|
app:
|
||||||
# build:
|
# build:
|
||||||
# context: .
|
# context: .
|
||||||
# dockerfile: docker/dockerfile/Dockerfile
|
# dockerfile: docker/dockerfile/Dockerfile
|
||||||
# target: prod
|
# target: prod
|
||||||
image: solucetechnologies/portabase:1.1.3-rc.2
|
image: solucetechnologies/portabase:1.1.3-rc.3
|
||||||
ports:
|
ports:
|
||||||
- '8887:80'
|
- '8887:80'
|
||||||
env_file:
|
env_file:
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import {NextRequest, NextResponse} from "next/server";
|
||||||
import { loggingMiddleware } from "@/middleware/loggingMiddleware";
|
import {loggingMiddleware} from "@/middleware/loggingMiddleware";
|
||||||
import { errorHandler } from "@/middleware/errorHandler";
|
import {errorHandler} from "@/middleware/errorHandler";
|
||||||
import { auth } from "@/lib/auth/auth";
|
import {auth} from "@/lib/auth/auth";
|
||||||
import { headers } from "next/headers";
|
import {headers} from "next/headers";
|
||||||
import { signOut } from "@/lib/auth/auth-client";
|
|
||||||
|
|
||||||
export async function proxy(request: NextRequest) {
|
export async function proxy(request: NextRequest) {
|
||||||
const url = request.nextUrl.clone();
|
const url = request.nextUrl.clone();
|
||||||
@@ -13,25 +12,20 @@ export async function proxy(request: NextRequest) {
|
|||||||
const session = await auth.api.getSession({
|
const session = await auth.api.getSession({
|
||||||
headers: await headers(),
|
headers: await headers(),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
return NextResponse.redirect(new URL(`/login?redirect=${redirectUrl}`, request.url));
|
return NextResponse.redirect(new URL(`/login?redirect=${redirectUrl}`, request.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session.user.banned) {
|
if (session.user.banned) {
|
||||||
signOut();
|
await auth.api.signOut({headers: await headers()});
|
||||||
return NextResponse.redirect(new URL("/login?error=banned", request.url));
|
return NextResponse.redirect(new URL("/login?error=banned", request.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session.user.role === "pending") {
|
if (session.user.role === "pending") {
|
||||||
signOut();
|
await auth.api.signOut({headers: await headers()});
|
||||||
return NextResponse.redirect(new URL(`/login?error=pending?redirect=${redirectUrl}`, request.url));
|
return NextResponse.redirect(new URL(`/login?error=pending?redirect=${redirectUrl}`, request.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url.pathname === "/dashboard") {
|
if (url.pathname === "/dashboard") {
|
||||||
return NextResponse.redirect(new URL(`/dashboard/home`, request.url));
|
return NextResponse.redirect(new URL(`/dashboard/home`, request.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.next();
|
return NextResponse.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,9 +36,9 @@ export async function proxy(request: NextRequest) {
|
|||||||
if (url.pathname.startsWith("/api")) {
|
if (url.pathname.startsWith("/api")) {
|
||||||
const routeExists = checkRouteExists(url.pathname);
|
const routeExists = checkRouteExists(url.pathname);
|
||||||
if (!routeExists) {
|
if (!routeExists) {
|
||||||
return new NextResponse(JSON.stringify({ message: "This API route does not exist.", status: 404 }), {
|
return new NextResponse(JSON.stringify({message: "This API route does not exist.", status: 404}), {
|
||||||
status: 404,
|
status: 404,
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: {"Content-Type": "application/json"},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,11 @@ import {createAuthClient} from "better-auth/react";
|
|||||||
import {adminClient, inferAdditionalFields, organizationClient} from "better-auth/client/plugins";
|
import {adminClient, inferAdditionalFields, organizationClient} from "better-auth/client/plugins";
|
||||||
import {ac, user, admin as adminRole, pending, superadmin, orgAdmin, orgMember, orgOwner} from "./permissions";
|
import {ac, user, admin as adminRole, pending, superadmin, orgAdmin, orgMember, orgOwner} from "./permissions";
|
||||||
import {auth} from "@/lib/auth/auth";
|
import {auth} from "@/lib/auth/auth";
|
||||||
|
import {getServerUrl} from "@/utils/get-server-url";
|
||||||
|
|
||||||
const baseURL =
|
const res = await fetch(`${getServerUrl()}/api/config`);
|
||||||
typeof window === "undefined"
|
const {PROJECT_URL} = await res.json();
|
||||||
? process.env.PROJECT_URL // server side
|
console.log(PROJECT_URL);
|
||||||
: "";
|
|
||||||
|
|
||||||
const res = await fetch(`${baseURL}/api/config`);
|
|
||||||
const { PROJECT_URL } = await res.json();
|
|
||||||
|
|
||||||
export const authClient = createAuthClient({
|
export const authClient = createAuthClient({
|
||||||
baseURL: PROJECT_URL,
|
baseURL: PROJECT_URL,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export const getServerUrl = () => {
|
|||||||
return window.location.origin;
|
return window.location.origin;
|
||||||
}
|
}
|
||||||
if (env.NODE_ENV === "development") {
|
if (env.NODE_ENV === "development") {
|
||||||
return `${env.NEXT_PUBLIC_PROJECT_URL}`;
|
return `${env.PROJECT_URL}`;
|
||||||
}
|
}
|
||||||
return `${env.NEXT_PUBLIC_PROJECT_URL}`;
|
return `${env.PROJECT_URL}`;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user