From 852a34fd2eef85d2979bba8310cbc0fe320b5f75 Mon Sep 17 00:00:00 2001 From: Sufiyan Date: Fri, 18 Oct 2024 19:06:10 +0530 Subject: [PATCH] Revert making request to absolute URLS. - add http prefix from backend itself. --- .../core/examples/server/ExamplesInteractiveServer.kt | 2 +- core/src/main/resources/templates/examples/index.html | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/kotlin/io/specmatic/core/examples/server/ExamplesInteractiveServer.kt b/core/src/main/kotlin/io/specmatic/core/examples/server/ExamplesInteractiveServer.kt index 3a2234d2e..066ca3f00 100644 --- a/core/src/main/kotlin/io/specmatic/core/examples/server/ExamplesInteractiveServer.kt +++ b/core/src/main/kotlin/io/specmatic/core/examples/server/ExamplesInteractiveServer.kt @@ -53,7 +53,7 @@ class ExamplesInteractiveServer( } private fun getServerHostPort(request: ExamplePageRequest? = null) : String { - return request?.hostPort ?: "localhost:$serverPort" + return request?.hostPort ?: "http://localhost:$serverPort" } private val environment = applicationEngineEnvironment { diff --git a/core/src/main/resources/templates/examples/index.html b/core/src/main/resources/templates/examples/index.html index 0d39185b0..3ab10c7e2 100644 --- a/core/src/main/resources/templates/examples/index.html +++ b/core/src/main/resources/templates/examples/index.html @@ -1558,7 +1558,7 @@

async function generateExample(pathInfo) { try { - const resp = await fetch(`http://${getHostPort()}/_specmatic/examples/generate`, { + const resp = await fetch(`${getHostPort()}/_specmatic/examples/generate`, { method: "POST", body: JSON.stringify(pathInfo), headers: { @@ -1575,7 +1575,7 @@

async function validateExample(exampleFile) { try { - const resp = await fetch(`http://${getHostPort()}/_specmatic/examples/validate`, { + const resp = await fetch(`${getHostPort()}/_specmatic/examples/validate`, { method: "POST", body: JSON.stringify({ exampleFile }), headers: { @@ -1593,7 +1593,7 @@

async function getExampleContent(example) { const exampleFileName = encodeURIComponent(example); try { - const resp = await fetch(`http://${getHostPort()}/_specmatic/examples/content?fileName=${exampleFileName}`) + const resp = await fetch(`${getHostPort()}/_specmatic/examples/content?fileName=${exampleFileName}`) const data = await resp.json(); if (!resp.ok) { @@ -1608,7 +1608,7 @@

async function testExample(exampleData) { try { - const resp = await fetch(`http://${getHostPort()}/_specmatic/examples/test`, { + const resp = await fetch(`${getHostPort()}/_specmatic/examples/test`, { method: "POST", body: JSON.stringify(exampleData), headers: {