Skip to content

Commit d9c95fb

Browse files
committed
fix build phase
1 parent eae542c commit d9c95fb

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/Try.res

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,25 @@ let default = props => {
4949
}
5050

5151
let getStaticProps: Next.GetStaticProps.t<props, _> = async _ => {
52-
let bundleBaseUrl = switch (Node.Process.Env.playgroundBundleEndpoint, Node.Process.Env.nodeEnv) {
53-
| (Some(baseUrl), _) => baseUrl
54-
| (None, "development") => "https://cdn.rescript-lang.org"
55-
| (None, _) => ""
52+
let (bundleBaseUrl, versionsBaseUrl) = switch (
53+
Node.Process.Env.playgroundBundleEndpoint,
54+
Node.Process.Env.nodeEnv,
55+
) {
56+
| (Some(baseUrl), _) => (baseUrl, baseUrl)
57+
| (None, "development") => {
58+
// Use remote bundles in dev
59+
let baseUrl = "https://cdn.rescript-lang.org"
60+
(baseUrl, baseUrl)
61+
}
62+
| (None, _) => (
63+
// Use same-origin requests for the bundle
64+
"",
65+
// There is no version endpoint in the build phase
66+
"https://cdn.rescript-lang.org",
67+
)
5668
}
5769
let versions = {
58-
let response = await fetch(bundleBaseUrl + "/playground-bundles/versions.json")
70+
let response = await fetch(versionsBaseUrl + "/playground-bundles/versions.json")
5971
let json = await WebAPI.Response.json(response)
6072
json
6173
->JSON.Decode.array

0 commit comments

Comments
 (0)