mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-02-23 15:12:52 +08:00
fix env handling
This commit is contained in:
parent
4531d7a597
commit
c0596e2ea6
@ -9,6 +9,7 @@ const proxyHost = process.env.proxyHost || 'http://localhost:8080';
|
||||
const authHost = process.env.authHost || 'http://localhost:8000';
|
||||
const publicHost = process.env.PUBLIC_HOST || 'http://localhost:3000';
|
||||
const host = process.env.host || 'localhost';
|
||||
const nodeEnv = process.env.NODE_ENV;
|
||||
|
||||
export default {
|
||||
telemetry: false,
|
||||
@ -24,6 +25,14 @@ export default {
|
||||
],
|
||||
},
|
||||
|
||||
env: {
|
||||
proxyHost,
|
||||
authHost,
|
||||
publicHost,
|
||||
host,
|
||||
nodeEnv,
|
||||
},
|
||||
|
||||
// Global CSS: https://go.nuxtjs.dev/config-css
|
||||
css: ['~/assets/main.scss'],
|
||||
|
||||
|
@ -30,7 +30,7 @@ const createApi = ({ $axios, store, app: { $cookies } }: Context) => {
|
||||
path: '/',
|
||||
expires: new Date(Date.now() + value.data.expiresIn * 1000),
|
||||
sameSite: 'strict',
|
||||
secure: process.env.NODE_ENV === 'production',
|
||||
secure: process.env.nodeEnv === 'production',
|
||||
});
|
||||
resolve(value.data.token);
|
||||
})
|
||||
|
@ -2,17 +2,15 @@ import { Context } from '@nuxt/types';
|
||||
import { Inject } from '@nuxt/types/app';
|
||||
import { User } from 'hangar-api';
|
||||
|
||||
const publicHost = process.env.PUBLIC_HOST ? process.env.PUBLIC_HOST : 'http://localhost:3000';
|
||||
|
||||
const createAuth = ({ app: { $cookies }, $axios, store, $api, redirect }: Context) => {
|
||||
class Auth {
|
||||
login(redirect: string): void {
|
||||
$cookies.set('returnRoute', redirect, {
|
||||
path: '/',
|
||||
maxAge: 120,
|
||||
secure: process.env.NODE_ENV === 'production',
|
||||
secure: process.env.nodeEnv === 'production',
|
||||
});
|
||||
location.replace(`/login?returnUrl=${publicHost}${redirect}`);
|
||||
location.replace(`/login?returnUrl=${process.env.publicHost}${redirect}`);
|
||||
}
|
||||
|
||||
processLogin(token: string): Promise<void> {
|
||||
|
Loading…
Reference in New Issue
Block a user