Skip to content

Allow for separate t3 options on the server and client - #364

Open
lleicher-sg wants to merge 1 commit into
TYPO3-Headless:mainfrom
lleicher-sg:server-sided-t3-options
Open

Allow for separate t3 options on the server and client#364
lleicher-sg wants to merge 1 commit into
TYPO3-Headless:mainfrom
lleicher-sg:server-sided-t3-options

Conversation

@lleicher-sg

Copy link
Copy Markdown

Right now, it is not possible to use different options for typo3 on the server and client.
The nuxt-typo3 documentation describes the usage of a server-only url, but that seems to be incompatible with the useT3Options() composable.

Use Case

When hosting a Typo3 Headless + Nuxt app in Docker, it would be nice to use a "fast" URL towards the typo3 server to bypass potential reverse-proxies.
E.g. three containers "nginx", "nuxt" and "typo3". Is a reverse proxy handling SSL termination and redirects to nuxt or typo3, depending on the hostname.
If this described setup is tested locally, direct communication is even required when using entries in /etc/hosts to 127.0.0.1...

Problem

Currently, Nuxt SSR has to fetch using the "public" https url (the same as the client), because of the way the useT3Options() composable is implemented:

// useT3Options.ts
const options = useRuntimeConfig().public.typo3 as T3Options

So any non-public runtime config is just ignored.

Additionally, the useT3OptionsState() composable uses a useState() which transfers server configuration to the client via hydration.

Proposal

The T3OptionsState should not be transferred to the client, but instead be rebuilt upon calling useT3Options().
This way, we can safely read from the non-public runtime config for SSR.
This PR does exactly that.
I am not sure if this covers all usages of useT3Options() in the library itself.
I've tested it in a project headless Typo3 project as drop-in replacement and it seems to be working just fine.

This could potentially introduce a breaking-change for projects using the useT3OptionsState() directly.

I think it would be better to support server-/client-sided-options to allow for more flexibility in hosting requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant