Skip to content

Commit af1edac

Browse files
committed
fix: cloudflare worker compatibility date
1 parent 2a78723 commit af1edac

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

terraform/cloudflare/turnstile.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
resource "cloudflare_turnstile_widget" "flow_php" {
22
account_id = cloudflare_account.account.id
33
name = "Flow PHP"
4-
domains = ["flow-php.com", "www.flow-php.com", "flow-php.wip"]
4+
domains = ["flow-php.com"]
55
mode = "managed"
66
region = "world"
77
}

terraform/cloudflare/workers.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ resource "cloudflare_workers_script" "snippet_upload" {
44
content = file("${path.module}/workers/snippet-upload.js")
55
main_module = "snippet-upload.js"
66

7+
compatibility_date = "2024-01-01"
8+
79
bindings = [
810
{
911
name = "SNIPPETS_BUCKET"
@@ -30,6 +32,6 @@ resource "cloudflare_workers_script" "snippet_upload" {
3032

3133
resource "cloudflare_workers_route" "snippet_upload" {
3234
zone_id = cloudflare_zone.flow_php.id
33-
pattern = "flow-php.com/api/playground/snippets*"
35+
pattern = "https://flow-php.com/api/playground/snippets*"
3436
script = cloudflare_workers_script.snippet_upload.script_name
3537
}

terraform/cloudflare/workers/snippet-upload.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,7 @@ async function hashIP(ip) {
672672
const data = encoder.encode(ip)
673673
const hashBuffer = await crypto.subtle.digest('SHA-256', data)
674674
const hashArray = Array.from(new Uint8Array(hashBuffer))
675-
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
676-
677-
return hashHex
675+
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
678676
}
679677

680678
/**
@@ -858,7 +856,6 @@ function getCorsHeaders(request, env) {
858856
// Define allowed origins
859857
const allowedOrigins = [
860858
'https://flow-php.com',
861-
'https://www.flow-php.com',
862859
'https://flow-php.wip'
863860
]
864861

web/landing/assets/controllers/playground_share_controller.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,12 @@ export default class extends Controller {
381381

382382
for (let i = 0; i < datasets.length && i < 3; i++) {
383383
const dataset = datasets[i]
384+
385+
if (!dataset.name || dataset.name.trim().length === 0) {
386+
this.#logError('Skipping dataset with empty name:', dataset)
387+
continue
388+
}
389+
384390
const result = await this.wasmOutlet.readFile(dataset.path)
385391
if (result.success) {
386392
const blob = new Blob([result.content], { type: 'application/octet-stream' })

0 commit comments

Comments
 (0)