mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-04-06 15:30:30 +08:00
fix: Fix next auth session provider base path
This commit is contained in:
parent
6223783b84
commit
715cdf2cc4
7
.vscode/extensions.json
vendored
7
.vscode/extensions.json
vendored
@ -1,8 +1,3 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"arcanis.vscode-zipfs",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"samuelcolvin.jinjahtml"
|
||||
]
|
||||
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "samuelcolvin.jinjahtml"]
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { SessionProvider, signIn, signOut, useSession } from 'next-auth/react';
|
||||
|
||||
import lowdefyConfig from '../../build/config.json';
|
||||
|
||||
function Session({ children }) {
|
||||
const wasAuthenticated = useRef(false);
|
||||
const { data: session, status } = useSession();
|
||||
@ -40,9 +42,12 @@ function Session({ children }) {
|
||||
|
||||
function AuthConfigured({ authConfig, children, serverSession }) {
|
||||
const auth = { signIn, signOut, authConfig };
|
||||
|
||||
let basePath = process.env.LOWDEFY_BASE_PATH ?? lowdefyConfig.basePath;
|
||||
if (basePath) {
|
||||
basePath = `${basePath}/api/auth`;
|
||||
}
|
||||
return (
|
||||
<SessionProvider session={serverSession}>
|
||||
<SessionProvider session={serverSession} basePath={basePath}>
|
||||
<Session>
|
||||
{(session) => {
|
||||
auth.session = session;
|
||||
|
@ -18,6 +18,8 @@
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { SessionProvider, signIn, signOut, useSession } from 'next-auth/react';
|
||||
|
||||
import lowdefyConfig from '../../build/config.json';
|
||||
|
||||
function Session({ children }) {
|
||||
const wasAuthenticated = useRef(false);
|
||||
const { data: session, status } = useSession();
|
||||
@ -40,9 +42,12 @@ function Session({ children }) {
|
||||
|
||||
function AuthConfigured({ authConfig, children, serverSession }) {
|
||||
const auth = { signIn, signOut, authConfig };
|
||||
|
||||
let basePath = process.env.LOWDEFY_BASE_PATH ?? lowdefyConfig.basePath;
|
||||
if (basePath) {
|
||||
basePath = `${basePath}/api/auth`;
|
||||
}
|
||||
return (
|
||||
<SessionProvider session={serverSession}>
|
||||
<SessionProvider session={serverSession} basePath={basePath}>
|
||||
<Session>
|
||||
{(session) => {
|
||||
auth.session = session;
|
||||
|
@ -2,7 +2,7 @@ const withLess = require('next-with-less');
|
||||
const lowdefyConfig = require('./build/config.json');
|
||||
|
||||
module.exports = withLess({
|
||||
basePath: process.env.LOWDEFY_BASE_PATH || lowdefyConfig.basePath,
|
||||
basePath: process.env.LOWDEFY_BASE_PATH ?? lowdefyConfig.basePath,
|
||||
reactStrictMode: true,
|
||||
webpack: (config, { isServer }) => {
|
||||
if (!isServer) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user