mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-01-15 01:14:27 -05:00
Merge branch 'development' into main
This commit is contained in:
commit
395f618bb2
23 changed files with 1938 additions and 1820 deletions
8
.dockerignore
Normal file
8
.dockerignore
Normal file
|
@ -0,0 +1,8 @@
|
|||
backend/dist/
|
||||
backend/node_modules/
|
||||
|
||||
frontend/node_modules/
|
||||
frontend/.next/
|
||||
frontend/dist/
|
||||
|
||||
**/.git/
|
|
@ -1,12 +1,5 @@
|
|||
# DATABASE
|
||||
DB_URL="postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}/pingvin-share?schema=public"
|
||||
DB_USER=postgres
|
||||
DB_PASSWORD=postgres
|
||||
DB_HOST=db:5432
|
||||
|
||||
# GENERAL
|
||||
APP_URL=http://localhost:3000
|
||||
BACKEND_URL=http://backend:8080
|
||||
SHOW_HOME_PAGE=true
|
||||
ALLOW_REGISTRATION=true
|
||||
MAX_FILE_SIZE=1000000000
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
name: Create Docker Image for Backend
|
||||
name: Create Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: main
|
||||
paths:
|
||||
- "backend/**"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
@ -18,8 +16,8 @@ jobs:
|
|||
uses: docker/setup-buildx-action@v1
|
||||
- name: login to docker registry
|
||||
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
||||
- name: build the image
|
||||
- name: Build the image
|
||||
run: |
|
||||
cd backend && docker buildx build --push \
|
||||
--tag stonith404/pingvin-share-backend:latest \
|
||||
docker buildx build --push \
|
||||
--tag stonith404/pingvin-share:latest \
|
||||
--platform linux/amd64,linux/arm64 .
|
25
.github/workflows/docker-image-frontend.yml
vendored
25
.github/workflows/docker-image-frontend.yml
vendored
|
@ -1,25 +0,0 @@
|
|||
name: Create Docker Image for Frontend
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: main
|
||||
paths:
|
||||
- "frontend/**"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: login to docker registry
|
||||
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
||||
- name: build the image
|
||||
run: |
|
||||
cd frontend && docker buildx build --push \
|
||||
--tag stonith404/pingvin-share-frontend:latest \
|
||||
--platform linux/amd64,linux/arm64 .
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -36,4 +36,5 @@ yarn-error.log*
|
|||
|
||||
# project specific
|
||||
/backend/uploads/
|
||||
/uploads/
|
||||
/data/
|
||||
/backend/prisma/pingvin-share.db*
|
||||
|
|
38
Dockerfile
Normal file
38
Dockerfile
Normal file
|
@ -0,0 +1,38 @@
|
|||
FROM node:18-alpine AS frontend-builder
|
||||
WORKDIR /opt/app
|
||||
COPY frontend/package.json frontend/package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY ./frontend .
|
||||
RUN npm run build
|
||||
|
||||
FROM node:18 AS backend-builder
|
||||
WORKDIR /opt/app
|
||||
COPY backend/package.json backend/package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY ./backend .
|
||||
RUN npx prisma generate
|
||||
RUN npm run build
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
FROM node:18 AS runner
|
||||
WORKDIR /opt/app/frontend
|
||||
ENV NODE_ENV=production
|
||||
COPY --from=frontend-builder /opt/app/next.config.js .
|
||||
COPY --from=frontend-builder /opt/app/public ./public
|
||||
COPY --from=frontend-builder /opt/app/.next ./.next
|
||||
COPY --from=frontend-builder /opt/app/node_modules ./node_modules
|
||||
|
||||
WORKDIR /opt/app/backend
|
||||
COPY --from=backend-builder /opt/app/node_modules ./node_modules
|
||||
COPY --from=backend-builder /opt/app/dist ./dist
|
||||
COPY --from=backend-builder /opt/app/prisma ./prisma
|
||||
COPY --from=backend-builder /opt/app/package.json ./
|
||||
WORKDIR /opt/app
|
||||
|
||||
RUN npm i -g dotenv-cli
|
||||
|
||||
EXPOSE 3000
|
||||
CMD cd frontend && dotenv -e .env.development node_modules/.bin/next start & cd backend && npm run prod
|
19
README.md
19
README.md
|
@ -21,20 +21,26 @@ Demo: https://pingvin-share.dev.eliasschneider.com
|
|||
|
||||
1. Download the `docker-compose.yml` and `.env.example` file.
|
||||
2. Rename the `.env.example` file to `.env` and change the environment variables so that they fit to your environment. If you need help with the environment variables take a look [here](#environment-variables)
|
||||
3. Run `docker-compose up -d`
|
||||
3. Create a folder in the same folder as your `docker-compose.yml` file named `data` and create a file named `pingvin-share.db` in it.
|
||||
4. Run `docker-compose up -d`
|
||||
|
||||
The website is now listening available on `http://localhost:3000`, have fun with Pingvin Share 🐧!
|
||||
|
||||
### Environment variables
|
||||
|
||||
| Variable | Description | Possible values |
|
||||
| -------------------- | --------------------------------------------------------------------------------------------------------------------- | --------------- |
|
||||
| -------------------- | ------------------------------------------------------------------------------------------- | --------------- |
|
||||
| `APP_URL` | On which URL Pingvin Share is available. E.g http://localhost or https://pingvin-share.com. | URL |
|
||||
| `BACKEND_URL` | Where the backend is listening on your local machine. If you use the default installation, use `http://backend:8080`. | URL |
|
||||
| `SHOW_HOME_PAGE` | Whether the Pingvin Share home page should be shown. | true/false |
|
||||
| `ALLOW_REGISTRATION` | Whether a new user can create a new account. | true/false |
|
||||
| `MAX_FILE_SIZE` | Maximum allowed size per file in bytes. | Number |
|
||||
| `JWT_SECRET` | Random string to sign the JWT's. | Long random string |
|
||||
| `JWT_SECRET` | Long random string to sign the JWT's. | Random string |
|
||||
|
||||
### Upgrade to a new version
|
||||
|
||||
Just updated the docker container by running `docker-compose pull && docker-compose up -d`
|
||||
|
||||
>Note: If you installed Pingvin Share before it used Sqlite, you unfortunately have to set up the project from scratch again, sorry for that.
|
||||
|
||||
## 🖤 Contribute
|
||||
|
||||
|
@ -48,9 +54,8 @@ Contact me, create an issue or directly create a pull request.
|
|||
1. Open the `backend` folder
|
||||
2. Duplicate the `.env.example` file, rename the duplicate to `.env` and change the environment variables if needed
|
||||
3. Install the dependencies with `npm install`
|
||||
4. Start the database by running `docker-compose up -d`
|
||||
5. Push the database schema to the database by running `npx prisma db push`
|
||||
6. Start the backend with `npm run dev`
|
||||
4. Push the database schema to the database by running `npx prisma db push`
|
||||
5. Start the backend with `npm run dev`
|
||||
|
||||
#### Frontend
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
node_modules/
|
||||
/frontend/node_modules/
|
||||
dist/
|
||||
.git/
|
|
@ -1,12 +1,7 @@
|
|||
# Environment variables declared in this file are automatically made available to Prisma.
|
||||
|
||||
DB_URL="postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}/pingvin-share?schema=public"
|
||||
DB_USER=postgres
|
||||
DB_PASSWORD=postgres
|
||||
DB_HOST=localhost:5432
|
||||
|
||||
# CONFIGURATION
|
||||
APP_URL=http://localhost:3000
|
||||
ALLOW_REGISTRATION=true
|
||||
MAX_FILE_SIZE=5000000000
|
||||
|
||||
JWT_SECRET=csdkdfmfdfdkslfjskl3987rfkhjgdfnkjdf
|
||||
# SECURITY
|
||||
JWT_SECRET=random-string
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
-- CreateTable
|
||||
CREATE TABLE "User" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"email" TEXT NOT NULL,
|
||||
"password" TEXT NOT NULL,
|
||||
"firstName" TEXT,
|
||||
"lastName" TEXT,
|
||||
|
||||
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "RefreshToken" (
|
||||
"token" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"expiresAt" TIMESTAMP(3) NOT NULL DEFAULT NOW() + interval '3 months',
|
||||
"userId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "RefreshToken_pkey" PRIMARY KEY ("token")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Share" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"uploadLocked" BOOLEAN NOT NULL DEFAULT false,
|
||||
"isZipReady" BOOLEAN NOT NULL DEFAULT false,
|
||||
"views" INTEGER NOT NULL DEFAULT 0,
|
||||
"expiration" TIMESTAMP(3) NOT NULL,
|
||||
"creatorId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "Share_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "File" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"name" TEXT NOT NULL,
|
||||
"size" TEXT NOT NULL,
|
||||
"shareId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "File_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ShareSecurity" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"password" TEXT,
|
||||
"maxViews" INTEGER,
|
||||
"shareId" TEXT,
|
||||
|
||||
CONSTRAINT "ShareSecurity_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ShareSecurity_shareId_key" ON "ShareSecurity"("shareId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "RefreshToken" ADD CONSTRAINT "RefreshToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Share" ADD CONSTRAINT "Share_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "File" ADD CONSTRAINT "File_shareId_fkey" FOREIGN KEY ("shareId") REFERENCES "Share"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ShareSecurity" ADD CONSTRAINT "ShareSecurity_shareId_fkey" FOREIGN KEY ("shareId") REFERENCES "Share"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
57
backend/prisma/migrations/20221011172612_init/migration.sql
Normal file
57
backend/prisma/migrations/20221011172612_init/migration.sql
Normal file
|
@ -0,0 +1,57 @@
|
|||
-- CreateTable
|
||||
CREATE TABLE "User" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL,
|
||||
"email" TEXT NOT NULL,
|
||||
"password" TEXT NOT NULL,
|
||||
"firstName" TEXT,
|
||||
"lastName" TEXT
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "RefreshToken" (
|
||||
"token" TEXT NOT NULL PRIMARY KEY,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"expiresAt" DATETIME NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
CONSTRAINT "RefreshToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Share" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"uploadLocked" BOOLEAN NOT NULL DEFAULT false,
|
||||
"isZipReady" BOOLEAN NOT NULL DEFAULT false,
|
||||
"views" INTEGER NOT NULL DEFAULT 0,
|
||||
"expiration" DATETIME NOT NULL,
|
||||
"creatorId" TEXT NOT NULL,
|
||||
CONSTRAINT "Share_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "File" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"name" TEXT NOT NULL,
|
||||
"size" TEXT NOT NULL,
|
||||
"shareId" TEXT NOT NULL,
|
||||
CONSTRAINT "File_shareId_fkey" FOREIGN KEY ("shareId") REFERENCES "Share" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ShareSecurity" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"password" TEXT,
|
||||
"maxViews" INTEGER,
|
||||
"shareId" TEXT,
|
||||
CONSTRAINT "ShareSecurity_shareId_fkey" FOREIGN KEY ("shareId") REFERENCES "Share" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ShareSecurity_shareId_key" ON "ShareSecurity"("shareId");
|
|
@ -1,3 +1,3 @@
|
|||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (i.e. Git)
|
||||
provider = "postgresql"
|
||||
provider = "sqlite"
|
|
@ -3,8 +3,8 @@ generator client {
|
|||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DB_URL")
|
||||
provider = "sqlite"
|
||||
url = "file:./pingvin-share.db"
|
||||
}
|
||||
|
||||
model User {
|
||||
|
@ -25,7 +25,7 @@ model RefreshToken {
|
|||
token String @id @default(uuid())
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
expiresAt DateTime @default(dbgenerated("NOW() + interval '3 months'"))
|
||||
expiresAt DateTime
|
||||
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
|
|
|
@ -6,9 +6,9 @@ import {
|
|||
import { ConfigService } from "@nestjs/config";
|
||||
import { JwtService } from "@nestjs/jwt";
|
||||
import { User } from "@prisma/client";
|
||||
|
||||
import { PrismaClientKnownRequestError } from "@prisma/client/runtime";
|
||||
import * as argon from "argon2";
|
||||
import * as moment from "moment";
|
||||
import { PrismaService } from "src/prisma/prisma.service";
|
||||
import { AuthRegisterDTO } from "./dto/authRegister.dto";
|
||||
import { AuthSignInDTO } from "./dto/authSignIn.dto";
|
||||
|
@ -87,7 +87,9 @@ export class AuthService {
|
|||
|
||||
async createRefreshToken(userId: string) {
|
||||
const refreshToken = (
|
||||
await this.prisma.refreshToken.create({ data: { userId } })
|
||||
await this.prisma.refreshToken.create({
|
||||
data: { userId, expiresAt: moment().add(3, "months").toDate() },
|
||||
})
|
||||
).token;
|
||||
|
||||
return refreshToken;
|
||||
|
|
|
@ -8,7 +8,7 @@ export class PrismaService extends PrismaClient {
|
|||
super({
|
||||
datasources: {
|
||||
db: {
|
||||
url: config.get("DB_URL"),
|
||||
url: "file:./pingvin-share.db",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,43 +1,16 @@
|
|||
version: '3.8'
|
||||
services:
|
||||
db:
|
||||
image: postgres:14.1-alpine
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- POSTGRES_USER=${DB_USER}
|
||||
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
||||
- POSTGRES_DB=pingvin-share
|
||||
volumes:
|
||||
- pingvin-share-db:/var/lib/postgresql/data
|
||||
backend:
|
||||
image: stonith404/pingvin-share-backend
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- POSTGRES_USER=${DB_USER}
|
||||
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
||||
- DB_HOST=${DB_HOST}
|
||||
- DB_URL=postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}/pingvin-share?schema=public
|
||||
- APP_URL=${APP_URL}
|
||||
- ALLOW_REGISTRATION=${ALLOW_REGISTRATION}
|
||||
- MAX_FILE_SIZE=${MAX_FILE_SIZE}
|
||||
- JWT_SECRET=${JWT_SECRET}
|
||||
depends_on:
|
||||
- db
|
||||
volumes:
|
||||
- "./uploads:/opt/app/uploads"
|
||||
frontend:
|
||||
pingvin-share:
|
||||
image: stonith404/pingvin-share
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- '3000:3000'
|
||||
image: stonith404/pingvin-share-frontend
|
||||
- 3000:3000
|
||||
environment:
|
||||
- APP_URL=${APP_URL}
|
||||
- SHOW_HOME_PAGE=${SHOW_HOME_PAGE}
|
||||
- ALLOW_REGISTRATION=${ALLOW_REGISTRATION}
|
||||
- MAX_FILE_SIZE=${MAX_FILE_SIZE}
|
||||
- BACKEND_URL=${BACKEND_URL}
|
||||
depends_on:
|
||||
- backend
|
||||
|
||||
|
||||
- JWT_SECRET=${JWT_SECRET}
|
||||
volumes:
|
||||
pingvin-share-db:
|
||||
- "${PWD}/data/uploads:/opt/app/backend/uploads"
|
||||
- "${PWD}/data/pingvin-share.db:/opt/app/backend/prisma/pingvin-share.db"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
BACKEND_URL=http://localhost:8080
|
||||
SHOW_HOME_PAGE=true
|
||||
ALLOW_REGISTRATION=true
|
||||
MAX_FILE_SIZE=1000000000
|
|
@ -1,7 +1,6 @@
|
|||
FROM node:18-alpine AS deps
|
||||
WORKDIR /opt/app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
|
||||
FROM node:18-alpine AS builder
|
||||
ENV NODE_ENV=production
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/** @type {import('next').NextConfig} */
|
||||
|
||||
const withPWA = require("next-pwa");
|
||||
|
||||
const nextConfig = withPWA({
|
||||
pwa: {
|
||||
dest: "public",
|
||||
disable: process.env.NODE_ENV == "development"
|
||||
},
|
||||
const nextConfig = {
|
||||
publicRuntimeConfig: {
|
||||
ALLOW_REGISTRATION: process.env.ALLOW_REGISTRATION,
|
||||
SHOW_HOME_PAGE: process.env.SHOW_HOME_PAGE,
|
||||
MAX_FILE_SIZE: process.env.MAX_FILE_SIZE,
|
||||
BACKEND_URL: process.env.BACKEND_URL
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = nextConfig
|
||||
const withPWA = require("next-pwa")({
|
||||
dest: "public",
|
||||
disable: process.env.NODE_ENV == "development"
|
||||
});
|
||||
|
||||
|
||||
module.exports = withPWA(nextConfig);
|
||||
|
|
3393
frontend/package-lock.json
generated
3393
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -21,9 +21,10 @@
|
|||
"file-saver": "^2.0.5",
|
||||
"jose": "^4.8.1",
|
||||
"moment": "^2.29.3",
|
||||
"next": "12.1.5",
|
||||
"next": "^12.3.1",
|
||||
"next-cookies": "^2.0.3",
|
||||
"next-http-proxy-middleware": "^1.2.4",
|
||||
"next-pwa": "^5.5.2",
|
||||
"next-pwa": "^5.6.0",
|
||||
"react": "18.0.0",
|
||||
"react-dom": "18.0.0",
|
||||
"tabler-icons-react": "^1.44.0",
|
||||
|
|
|
@ -8,8 +8,9 @@ import {
|
|||
import { useColorScheme } from "@mantine/hooks";
|
||||
import { ModalsProvider } from "@mantine/modals";
|
||||
import { NotificationsProvider } from "@mantine/notifications";
|
||||
import { getCookie, setCookies } from "cookies-next";
|
||||
import { setCookies } from "cookies-next";
|
||||
import { GetServerSidePropsContext } from "next";
|
||||
import cookies from "next-cookies";
|
||||
import type { AppProps } from "next/app";
|
||||
import { useEffect, useState } from "react";
|
||||
import Footer from "../components/Footer";
|
||||
|
@ -22,9 +23,7 @@ import globalStyle from "../styles/mantine.style";
|
|||
import { CurrentUser } from "../types/user.type";
|
||||
import { GlobalLoadingContext } from "../utils/loading.util";
|
||||
|
||||
function App(
|
||||
props: AppProps & { colorScheme: ColorScheme; environmentVariables: any }
|
||||
) {
|
||||
function App(props: AppProps & { colorScheme: ColorScheme }) {
|
||||
const { Component, pageProps } = props;
|
||||
|
||||
const systemTheme = useColorScheme();
|
||||
|
@ -91,6 +90,6 @@ export default App;
|
|||
|
||||
App.getInitialProps = ({ ctx }: { ctx: GetServerSidePropsContext }) => {
|
||||
return {
|
||||
colorScheme: getCookie("color-schema", ctx) || "light",
|
||||
colorScheme: cookies(ctx)["color-schema"] || "light",
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import httpProxyMiddleware from "next-http-proxy-middleware";
|
||||
import getConfig from "next/config";
|
||||
|
||||
const { publicRuntimeConfig } = getConfig();
|
||||
|
||||
export const config = {
|
||||
api: {
|
||||
|
@ -15,5 +12,5 @@ export const config = {
|
|||
export default (req: NextApiRequest, res: NextApiResponse) =>
|
||||
httpProxyMiddleware(req, res, {
|
||||
// You can use the `http-proxy` option
|
||||
target: publicRuntimeConfig.BACKEND_URL,
|
||||
target: "http://localhost:8080",
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue