I have two applications that I have deployed to Digital Ocean using Laravel Forge. Both is building using Laravel, Vue, Inertia, Tailwindcss Stack. (inertia 1.0) When I try to start daemon for starting SSR for both server... the port seems to conflict and does not run the daemon as expected. If there is only one site.. everything works perfectly.
What is the issues.. and what is the right way of doing it.
Also another issue is the when I enter website2.com on browers it automatically redirects to website1.com. Both are on the same digital ocean droplet. But works good when I type the full url https://website2.com
As @campaign-center previously indicated, you can get both instances working with SSR by customizing the ports.
You can add the following variable to your .env
files. make sure the values are unique to each instance.
//.env
VITE_SSR_PORT=13714
Then update resources/js/ssr.tsx
accordingly: (This example uses React + TS. Should be similar to the rest).
// resources/js/ssr.tsx
const appName = import.meta.env.VITE_APP_NAME || "Laravel";
const ssrPort = import.meta.env.VITE_SSR_PORT || 13714; // Add this line
createServer(
(page) =>
createInertiaApp({
page,
render: ReactDOMServer.renderToString,
title: (title) => `${title} - ${appName}`,
resolve: (name) =>
resolvePageComponent(
`./Pages/${name}.tsx`,
import.meta.glob("./Pages/**/*.tsx")
),
setup: ({ App, props }) => {
global.route<RouteName> = (name, params, absolute) =>
route(name, params as any, absolute, {
// @ts-expect-error
...page.props.ziggy,
// @ts-expect-error
location: new URL(page.props.ziggy.location),
});
return <App {...props} />;
},
}),
ssrPort // Add this line
);
Build the app (npm run build
) followed by running the inertia ssr server php artisan inertia:start-ssr
.
npm run build
php artisan inertia:start-ssr