Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert making request to absolute URLS in Examples Interactive Server. #1363

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ExamplesInteractiveServer(
}

private fun getServerHostPort(request: ExamplePageRequest? = null) : String {
return request?.hostPort ?: "localhost:$serverPort"
return request?.hostPort ?: "http://localhost:$serverPort"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if this hardcoding will work?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not affect http POST based initial page load, so we are okay here

}

private val environment = applicationEngineEnvironment {
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/resources/templates/examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@ <h2 th:text="${contractFilePath}"></h2>

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: {
Expand All @@ -1575,7 +1575,7 @@ <h2 th:text="${contractFilePath}"></h2>

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: {
Expand All @@ -1593,7 +1593,7 @@ <h2 th:text="${contractFilePath}"></h2>
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) {
Expand All @@ -1608,7 +1608,7 @@ <h2 th:text="${contractFilePath}"></h2>

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: {
Expand Down