diff --git a/examples/tests/sdk_tests/website/two_websites.w b/examples/tests/sdk_tests/website/two_websites.w index 68f265eefb0..7f9749a3cdb 100644 --- a/examples/tests/sdk_tests/website/two_websites.w +++ b/examples/tests/sdk_tests/website/two_websites.w @@ -7,15 +7,6 @@ let w2 = new cloud.Website(path: "./website") as "website-2"; test "deploying two websites" { - let var url1 = w1.url; - if (!url1.startsWith("http")) { - url1 = "http://" + url1; - } - let var url2 = w2.url; - if (!url2.startsWith("http")) { - url2 = "http://" + url2; - } - - assert(http.get(url1).ok); - assert(http.get(url2).ok); + assert(http.get(w1.url).ok); + assert(http.get(w2.url).ok); } \ No newline at end of file diff --git a/examples/tests/sdk_tests/website/website.w b/examples/tests/sdk_tests/website/website.w index ce6ea441bac..83703fdaa18 100644 --- a/examples/tests/sdk_tests/website/website.w +++ b/examples/tests/sdk_tests/website/website.w @@ -18,12 +18,7 @@ assert(w.path.endsWith("sdk_tests/website/website") || w.path.endsWith("sdk_test test "access files on the website" { - let var url = w.url; - if (!url.startsWith("http")) { - url = "http://" + url; - } - - assert(http.get(url).body == indexFile); - assert(http.get(url + "/inner-folder/other.html").body == otherFile); - assert(http.get(url + "/config.json").body == Json.stringify(config)); + assert(http.get(w.url).body == indexFile); + assert(http.get(w.url + "/inner-folder/other.html").body == otherFile); + assert(http.get(w.url + "/config.json").body == Json.stringify(config)); } diff --git a/libs/wingsdk/src/target-tf-aws/website.ts b/libs/wingsdk/src/target-tf-aws/website.ts index 20acf78bbfc..f97af71174d 100644 --- a/libs/wingsdk/src/target-tf-aws/website.ts +++ b/libs/wingsdk/src/target-tf-aws/website.ts @@ -127,7 +127,7 @@ export class Website extends cloud.Website { policy: allowDistributionReadOnly.json, }); - this._url = distribution.domainName; + this._url = `https://${distribution.domainName}`; } public get url(): string { diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/website/two_websites.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/website/two_websites.w_compile_tf-aws.md index adbf1ea62b4..78443f755c1 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/website/two_websites.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/website/two_websites.w_compile_tf-aws.md @@ -10,16 +10,8 @@ module.exports = function({ $http_Util, $w1_url, $w2_url }) { return $obj; } async handle() { - let url1 = $w1_url; - if ((!url1.startsWith("http"))) { - url1 = ("http://" + url1); - } - let url2 = $w2_url; - if ((!url2.startsWith("http"))) { - url2 = ("http://" + url2); - } - {((cond) => {if (!cond) throw new Error("assertion failed: http.get(url1).ok")})((await $http_Util.get(url1)).ok)}; - {((cond) => {if (!cond) throw new Error("assertion failed: http.get(url2).ok")})((await $http_Util.get(url2)).ok)}; + {((cond) => {if (!cond) throw new Error("assertion failed: http.get(w1.url).ok")})((await $http_Util.get($w1_url)).ok)}; + {((cond) => {if (!cond) throw new Error("assertion failed: http.get(w2.url).ok")})((await $http_Util.get($w2_url)).ok)}; } } return $Closure1; @@ -304,8 +296,8 @@ module.exports = function({ $http_Util, $w1_url, $w2_url }) { "variables": { "WING_FUNCTION_NAME": "Handler-c8683851", "WING_TARGET": "tf-aws", - "WING_TOKEN_TFTOKEN_TOKEN_16": "${jsonencode(aws_cloudfront_distribution.cloudWebsite_Distribution_083B5AF9.domain_name)}", - "WING_TOKEN_TFTOKEN_TOKEN_32": "${jsonencode(aws_cloudfront_distribution.website-2_Distribution_F1FA4680.domain_name)}" + "WING_TOKEN_HTTPS_TFTOKEN_TOKEN_16": "${jsonencode(\"https://${aws_cloudfront_distribution.cloudWebsite_Distribution_083B5AF9.domain_name}\")}", + "WING_TOKEN_HTTPS_TFTOKEN_TOKEN_32": "${jsonencode(\"https://${aws_cloudfront_distribution.website-2_Distribution_F1FA4680.domain_name}\")}" } }, "function_name": "Handler-c8683851", @@ -583,8 +575,8 @@ class $Root extends $stdlib.std.Resource { } _registerBind(host, ops) { if (ops.includes("handle")) { - $Closure1._registerBindObject(w1.url, host, []); - $Closure1._registerBindObject(w2.url, host, []); + $Closure1._registerBindObject(w1.url, host, ["ok"]); + $Closure1._registerBindObject(w2.url, host, ["ok"]); } super._registerBind(host, ops); } diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/website/website.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/website/website.w_compile_tf-aws.md index 6df0053de3e..31cbdf4d941 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/website/website.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/website/website.w_compile_tf-aws.md @@ -10,13 +10,9 @@ module.exports = function({ $config, $http_Util, $indexFile, $otherFile, $std_Js return $obj; } async handle() { - let url = $w_url; - if ((!url.startsWith("http"))) { - url = ("http://" + url); - } - {((cond) => {if (!cond) throw new Error("assertion failed: http.get(url).body == indexFile")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((await $http_Util.get(url)).body,$indexFile)))}; - {((cond) => {if (!cond) throw new Error("assertion failed: http.get(url + \"/inner-folder/other.html\").body == otherFile")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((await $http_Util.get((url + "/inner-folder/other.html"))).body,$otherFile)))}; - {((cond) => {if (!cond) throw new Error("assertion failed: http.get(url + \"/config.json\").body == Json.stringify(config)")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((await $http_Util.get((url + "/config.json"))).body,((args) => { return JSON.stringify(args[0], null, args[1]) })([$config]))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: http.get(w.url).body == indexFile")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((await $http_Util.get($w_url)).body,$indexFile)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: http.get(w.url + \"/inner-folder/other.html\").body == otherFile")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((await $http_Util.get(($w_url + "/inner-folder/other.html"))).body,$otherFile)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: http.get(w.url + \"/config.json\").body == Json.stringify(config)")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((await $http_Util.get(($w_url + "/config.json"))).body,((args) => { return JSON.stringify(args[0], null, args[1]) })([$config]))))}; } } return $Closure1; @@ -217,7 +213,7 @@ module.exports = function({ }) { "variables": { "WING_FUNCTION_NAME": "Handler-c867c4e0", "WING_TARGET": "tf-aws", - "WING_TOKEN_TFTOKEN_TOKEN_16": "${jsonencode(aws_cloudfront_distribution.cloudWebsite_Distribution_083B5AF9.domain_name)}" + "WING_TOKEN_HTTPS_TFTOKEN_TOKEN_16": "${jsonencode(\"https://${aws_cloudfront_distribution.cloudWebsite_Distribution_083B5AF9.domain_name}\")}" } }, "function_name": "Handler-c867c4e0", @@ -449,7 +445,7 @@ class $Root extends $stdlib.std.Resource { $Closure1._registerBindObject(config, host, []); $Closure1._registerBindObject(indexFile, host, []); $Closure1._registerBindObject(otherFile, host, []); - $Closure1._registerBindObject(w.url, host, []); + $Closure1._registerBindObject(w.url, host, ["body"]); } super._registerBind(host, ops); }