Skip to content

Expose config.kit.server.https so that svelte-kit preview --https can use user-defined cert #1659

@alipi

Description

@alipi

Is your feature request related to a problem? Please describe.
Expose config.kit.server.https so that svelte-kit preview --https can use user-defined cert.

Describe the solution you'd like
Not tested, but suggested fix:

diff --git a/packages/kit/src/core/load_config/options.js b/packages/kit/src/core/load_config/options.js
index c763465..ba8eb88 100644
--- a/packages/kit/src/core/load_config/options.js
+++ b/packages/kit/src/core/load_config/options.js
@@ -139,6 +139,19 @@ const options = {
 
                        router: expect_boolean(true),
 
+                       server: {
+                               type: 'leaf',
+                               default: null,
+                               validate: (option, keypath) => {
+
+                                       if (!(option && option.https && option.https.cert && option.https.key)) {
+                                               throw new Error(`${keypath} server https cert & key not defined`);
+                                       }
+
+                                       return option;
+                               }
+                       },
+
                        ssr: expect_boolean(true),
 
                        target: expect_string(null),

However I've tested the patched built version:

diff --git a/node_modules/@sveltejs/kit/dist/cli.js b/node_modules/@sveltejs/kit/dist/cli.js
index 9914595..e829be3 100644
--- a/node_modules/@sveltejs/kit/dist/cli.js
+++ b/node_modules/@sveltejs/kit/dist/cli.js
@@ -277,6 +277,19 @@ const options = {
 
 			router: expect_boolean(true),
 
+                       server: {
+                               type: 'leaf',
+                               default: null,
+                               validate: (option, keypath) => {
+
+                                       if (!(option && option.https && option.https.cert && option.https.key)) {
+                                               throw new Error(`${keypath} server https cert & key not defined`);
+                                       }
+
+                                       return option;
+                               }
+                       },
+
 			ssr: expect_boolean(true),
 
 			target: expect_string(null),

Describe alternatives you've considered
N/A

How important is this feature to you?
Good to have, to be able to use existing self-signed certs during development.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions