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_KEY=soY8ZAtItT_fCkNUADfgffZUUo675lOj
|
||||
# App
|
||||
TZ=UTC
|
||||
PORT=3333
|
||||
HOST=localhost
|
||||
LOG_LEVEL=info
|
||||
LOG_LEVEL=debug
|
||||
APP_KEY=soY8ZAtItT_fCkNUADfgffZUUo675lOj # node ace generate:key
|
||||
NODE_ENV=development
|
||||
SESSION_DRIVER=cookie
|
||||
|
||||
# App url
|
||||
APP_URL=http://localhost:3333
|
||||
|
||||
# Database
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=5432
|
||||
DB_USER=root
|
||||
DB_PASSWORD=root
|
||||
DB_DATABASE=app
|
||||
|
||||
# Google
|
||||
GOOGLE_CLIENT_ID=
|
||||
GOOGLE_CLIENT_SECRET=
|
||||
GOOGLE_CLIENT_CALLBACK_URL=http://localhost:3333/auth/callback
|
||||
|
||||
@@ -5,7 +5,7 @@ const allyConfig = defineConfig({
|
||||
google: services.google({
|
||||
clientId: env.get('GOOGLE_CLIENT_ID'),
|
||||
clientSecret: env.get('GOOGLE_CLIENT_SECRET'),
|
||||
callbackUrl: env.get('GOOGLE_CLIENT_CALLBACK_URL'),
|
||||
callbackUrl: env.get('APP_URL') + '/auth/callback',
|
||||
prompt: 'select_account',
|
||||
display: 'page',
|
||||
scopes: ['userinfo.email', 'userinfo.profile'],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { isSSREnableForPage } from '#config/ssr';
|
||||
import env from '#start/env';
|
||||
import { DEFAULT_USER_THEME, KEY_USER_THEME } from '#user/constants/theme';
|
||||
import logger from '@adonisjs/core/services/logger';
|
||||
import { defineConfig } from '@adonisjs/inertia';
|
||||
@@ -24,6 +25,7 @@ export default defineConfig({
|
||||
isAuthenticated: ctx.auth?.isAuthenticated || false,
|
||||
};
|
||||
},
|
||||
appUrl: env.get('APP_URL'),
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { api } from '#adonis/api';
|
||||
import { PRIMARY_COLOR } from '#config/project';
|
||||
import { PageProps } from '@adonisjs/inertia/types';
|
||||
import { router, usePage } from '@inertiajs/react';
|
||||
import { router } from '@inertiajs/react';
|
||||
import {
|
||||
ColorSchemeScript,
|
||||
createTheme,
|
||||
@@ -15,6 +14,7 @@ import { TuyauProvider } from '@tuyau/inertia/react';
|
||||
import dayjs from 'dayjs';
|
||||
import { ReactNode, useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useAppUrl } from '~/hooks/use_app_url';
|
||||
import '../styles/index.css';
|
||||
|
||||
const TRANSITION_IN_CLASS = '__transition_fadeIn';
|
||||
@@ -73,12 +73,12 @@ const customTheme = createTheme({
|
||||
|
||||
export function BaseLayout({ children }: { children: ReactNode }) {
|
||||
const { i18n } = useTranslation();
|
||||
const appUrl = useAppUrl();
|
||||
dayjs.locale(i18n.language);
|
||||
const { props } = usePage<PageProps & { appBaseUrl: string }>();
|
||||
|
||||
const tuyauClient = createTuyau({
|
||||
api,
|
||||
baseUrl: props.appBaseUrl,
|
||||
baseUrl: appUrl,
|
||||
});
|
||||
|
||||
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
|
||||
|----------------------------------------------------------
|
||||
*/
|
||||
@@ -43,5 +50,4 @@ export default await Env.create(new URL('../', import.meta.url), {
|
||||
*/
|
||||
GOOGLE_CLIENT_ID: Env.schema.string(),
|
||||
GOOGLE_CLIENT_SECRET: Env.schema.string(),
|
||||
GOOGLE_CLIENT_CALLBACK_URL: Env.schema.string(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user