trypost/resources/js/app.ts
Paulo Castellano 48727c80cd feat(docker): add Caddy reverse proxy and domain-portable Reverb config
Add an optional Caddy service (proxy profile) to compose.prod.yaml for
automatic HTTPS on a custom domain, with a Caddyfile that transparently
proxies WebSocket upgrades.

Move Echo setup into resources/js/echo.ts and derive the Reverb host from
window.location when VITE_REVERB_* is unset, so the published image's frontend
connects on any domain without a rebuild. The release workflow bakes a fixed
public Reverb key and leaves host/port/scheme empty to enable this; the Herd
dev setup keeps its explicit VITE_REVERB_* values, so its behaviour is
unchanged.

Drop the now-unneeded 8080 host port — the WebSocket rides the main HTTP(S)
port via the in-container nginx /app proxy.
2026-05-27 14:53:46 -03:00

70 lines
2.4 KiB
TypeScript

import '../css/app.css';
import './echo';
import { createInertiaApp, router } from '@inertiajs/vue3';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { i18nVue } from 'laravel-vue-i18n';
import type { DefineComponent } from 'vue';
import { createApp, h } from 'vue';
import { initializeDataLayer } from './datalayer';
import dayjs from './dayjs';
import { capturePageview, initializePostHog, syncPostHogContext } from './posthog';
import type { Auth } from './types';
const appName = import.meta.env.VITE_APP_NAME || 'TryPost.it';
createInertiaApp({
title: (title) => (title ? `${title} - ${appName}` : appName),
resolve: (name) =>
resolvePageComponent(
`./pages/${name}.vue`,
import.meta.glob<DefineComponent>('./pages/**/*.vue'),
),
setup({ el, App, props, plugin }) {
// Get locale from shared Inertia props
const locale = (props.initialPage.props as { locale?: string })?.locale || 'en';
// Set dayjs locale based on user's language
dayjs.locale(locale.toLowerCase());
const auth = props.initialPage.props.auth as Auth | undefined;
const flash = props.initialPage.props.flash as
| { conversion_event?: string; [key: string]: unknown }
| undefined;
initializeDataLayer(
auth,
flash,
props.initialPage.props.applicationUrl as string,
props.initialPage.props.env as string,
);
// Initial PostHog identify + dual-group context + first pageview.
// The same hooks fire on every Inertia navigation below so the
// account group counts stay reactive and workspace switches
// re-attach the right workspace group.
initializePostHog();
syncPostHogContext(props.initialPage);
capturePageview();
router.on('navigate', (event) => {
syncPostHogContext(event.detail.page);
capturePageview();
});
createApp({ render: () => h(App, props) })
.use(i18nVue, {
lang: locale,
resolve: async (lang: string) => {
const langs = import.meta.glob('../../lang/*.json');
return await langs[`../../lang/php_${lang}.json`]();
},
})
.use(plugin)
.mount(el);
},
progress: {
color: '#4B5563',
},
});