mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 22:53:25 +00:00
fix: app base url shared in inertia config file
This commit is contained in:
14
.env.example
14
.env.example
@@ -1,16 +1,22 @@
|
|||||||
# node ace generate:key
|
# App
|
||||||
APP_KEY=soY8ZAtItT_fCkNUADfgffZUUo675lOj
|
|
||||||
TZ=UTC
|
TZ=UTC
|
||||||
PORT=3333
|
PORT=3333
|
||||||
HOST=localhost
|
HOST=localhost
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=debug
|
||||||
|
APP_KEY=soY8ZAtItT_fCkNUADfgffZUUo675lOj # node ace generate:key
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
SESSION_DRIVER=cookie
|
SESSION_DRIVER=cookie
|
||||||
|
|
||||||
|
# App url
|
||||||
|
APP_URL=http://localhost:3333
|
||||||
|
|
||||||
|
# Database
|
||||||
DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
DB_PORT=5432
|
DB_PORT=5432
|
||||||
DB_USER=root
|
DB_USER=root
|
||||||
DB_PASSWORD=root
|
DB_PASSWORD=root
|
||||||
DB_DATABASE=app
|
DB_DATABASE=app
|
||||||
|
|
||||||
|
# Google
|
||||||
GOOGLE_CLIENT_ID=
|
GOOGLE_CLIENT_ID=
|
||||||
GOOGLE_CLIENT_SECRET=
|
GOOGLE_CLIENT_SECRET=
|
||||||
GOOGLE_CLIENT_CALLBACK_URL=http://localhost:3333/auth/callback
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const allyConfig = defineConfig({
|
|||||||
google: services.google({
|
google: services.google({
|
||||||
clientId: env.get('GOOGLE_CLIENT_ID'),
|
clientId: env.get('GOOGLE_CLIENT_ID'),
|
||||||
clientSecret: env.get('GOOGLE_CLIENT_SECRET'),
|
clientSecret: env.get('GOOGLE_CLIENT_SECRET'),
|
||||||
callbackUrl: env.get('GOOGLE_CLIENT_CALLBACK_URL'),
|
callbackUrl: env.get('APP_URL') + '/auth/callback',
|
||||||
prompt: 'select_account',
|
prompt: 'select_account',
|
||||||
display: 'page',
|
display: 'page',
|
||||||
scopes: ['userinfo.email', 'userinfo.profile'],
|
scopes: ['userinfo.email', 'userinfo.profile'],
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { isSSREnableForPage } from '#config/ssr';
|
import { isSSREnableForPage } from '#config/ssr';
|
||||||
|
import env from '#start/env';
|
||||||
import { DEFAULT_USER_THEME, KEY_USER_THEME } from '#user/constants/theme';
|
import { DEFAULT_USER_THEME, KEY_USER_THEME } from '#user/constants/theme';
|
||||||
import logger from '@adonisjs/core/services/logger';
|
import logger from '@adonisjs/core/services/logger';
|
||||||
import { defineConfig } from '@adonisjs/inertia';
|
import { defineConfig } from '@adonisjs/inertia';
|
||||||
@@ -24,6 +25,7 @@ export default defineConfig({
|
|||||||
isAuthenticated: ctx.auth?.isAuthenticated || false,
|
isAuthenticated: ctx.auth?.isAuthenticated || false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
appUrl: env.get('APP_URL'),
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { api } from '#adonis/api';
|
import { api } from '#adonis/api';
|
||||||
import { PRIMARY_COLOR } from '#config/project';
|
import { PRIMARY_COLOR } from '#config/project';
|
||||||
import { PageProps } from '@adonisjs/inertia/types';
|
import { router } from '@inertiajs/react';
|
||||||
import { router, usePage } from '@inertiajs/react';
|
|
||||||
import {
|
import {
|
||||||
ColorSchemeScript,
|
ColorSchemeScript,
|
||||||
createTheme,
|
createTheme,
|
||||||
@@ -15,6 +14,7 @@ import { TuyauProvider } from '@tuyau/inertia/react';
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { ReactNode, useEffect } from 'react';
|
import { ReactNode, useEffect } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useAppUrl } from '~/hooks/use_app_url';
|
||||||
import '../styles/index.css';
|
import '../styles/index.css';
|
||||||
|
|
||||||
const TRANSITION_IN_CLASS = '__transition_fadeIn';
|
const TRANSITION_IN_CLASS = '__transition_fadeIn';
|
||||||
@@ -73,12 +73,12 @@ const customTheme = createTheme({
|
|||||||
|
|
||||||
export function BaseLayout({ children }: { children: ReactNode }) {
|
export function BaseLayout({ children }: { children: ReactNode }) {
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
|
const appUrl = useAppUrl();
|
||||||
dayjs.locale(i18n.language);
|
dayjs.locale(i18n.language);
|
||||||
const { props } = usePage<PageProps & { appBaseUrl: string }>();
|
|
||||||
|
|
||||||
const tuyauClient = createTuyau({
|
const tuyauClient = createTuyau({
|
||||||
api,
|
api,
|
||||||
baseUrl: props.appBaseUrl,
|
baseUrl: appUrl,
|
||||||
});
|
});
|
||||||
|
|
||||||
const findAppElement = () => document.getElementById('app');
|
const findAppElement = () => document.getElementById('app');
|
||||||
|
|||||||
@@ -27,6 +27,13 @@ export default await Env.create(new URL('../', import.meta.url), {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|----------------------------------------------------------
|
|----------------------------------------------------------
|
||||||
|
| Variables for configuring app url
|
||||||
|
|----------------------------------------------------------
|
||||||
|
*/
|
||||||
|
APP_URL: Env.schema.string({ format: 'url', tld: false }), // Remove TLD to allow localhost
|
||||||
|
|
||||||
|
/*
|
||||||
|
|----------------------------------------------------------
|
||||||
| Variables for configuring database connection
|
| Variables for configuring database connection
|
||||||
|----------------------------------------------------------
|
|----------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -43,5 +50,4 @@ export default await Env.create(new URL('../', import.meta.url), {
|
|||||||
*/
|
*/
|
||||||
GOOGLE_CLIENT_ID: Env.schema.string(),
|
GOOGLE_CLIENT_ID: Env.schema.string(),
|
||||||
GOOGLE_CLIENT_SECRET: Env.schema.string(),
|
GOOGLE_CLIENT_SECRET: Env.schema.string(),
|
||||||
GOOGLE_CLIENT_CALLBACK_URL: Env.schema.string(),
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user