0

I have a basic index.php page that on its turn includes a PHP file containing some variables in a JSON structure. The path of that PHP file is set via environment variables set in the virtualhost file.

index.php:

...
include CONFIG_SCRIPT_PATH;
...

domain.com.conf virtualhost file:

<VirtualHost *:443>
...
SetEnv CONFIG_SCRIPT_PATH ../../../config/domain.php
...

domain22.com.conf virtualhost file:

<VirtualHost *:443>
...
SetEnv CONFIG_SCRIPT_PATH ../../../config/domain22.php
...

That is useful because I have only one index.php page to maintain and I apply styles, etc. depending on the domain that loads it.

Now I'm migrating the frontend to sveltekit, but not the config files, that are loaded by other applications too.

How can I do this in sveltekit?

  • a single sveltekit project to read different environment variables depending on the domain that calls it
  • perform an equivalent to include CONFIG_SCRIPT_PATH;. I can make the PHP script export the variables to JSON.

I don't want the environment variables nor the contents of the config files to be called from the frontend or be exposed to the clients in any way, so everything has to happen serverside.

Can you point me into the right direction?

Thanks

Marc
  • 1,029
  • 1
  • 10
  • 27

0 Answers0