Setting up my first site with workers

I’ve an app that works fine locally.
Uploading it to Pages works fine until I make a request to one of my api routes. I then get a 500 error.

define is not defined sounds like a RequireJS problem, but I’ve no real idea how to approach this?

{
  "outcome": "ok",
  "scriptName": "pages-worker--2249669-production",
  "diagnosticsChannelEvents": [],
  "exceptions": [],
  "logs": [
    {
      "message": [
        "21:16:54 [ERROR] ReferenceError: define is not defined\n    at functionsWorker-0.5457881475471058.js:4573:3\n    at functionsWorker-0.5457881475471058.js:41:38\n    at functionsWorker-0.5457881475471058.js:10355:3\n    at functionsWorker-0.5457881475471058.js:41:38\n    at functionsWorker-0.5457881475471058.js:10372:44\n    at async _a3.render (functionsWorker-0.5457881475471058.js:12528:134)\n    at async Object.fetch (functionsWorker-0.5457881475471058.js:12651:42)"
      ],
      "level": "error",
      "timestamp": 1711315014732
    }
  ],
  "eventTimestamp": 1711315014717,
  "event": {
    "request": {
      "url": "https://thecarsearcher.com/api/enquiry",
      "method": "POST",
      "headers": {
        "accept": "*/*",
        "accept-encoding": "gzip, br",
        "accept-language": "en-GB,en-US;q=0.9,en;q=0.8",
        "cache-control": "no-cache",
        "cf-connecting-ip": "82.3.234.100",
        "cf-connecting-o2o": "1",
        "cf-ipcountry": "GB",
        "cf-ray": "8699af59cd8123ff",
        "cf-visitor": "{\"scheme\":\"https\"}",
        "connection": "Keep-Alive",
        "content-length": "20",
        "content-type": "text/plain;charset=UTF-8",
        "host": "thecarsearcher.com",
        "origin": "https://thecarsearcher.com",
        "pragma": "no-cache",
        "priority": "u=1, i",
        "referer": "https://thecarsearcher.com/",
        "sec-ch-ua": "\"Google Chrome\";v=\"123\", \"Not:A-Brand\";v=\"8\", \"Chromium\";v=\"123\"",
        "sec-ch-ua-mobile": "?1",
        "sec-ch-ua-platform": "\"Android\"",
        "sec-fetch-dest": "empty",
        "sec-fetch-mode": "cors",
        "sec-fetch-site": "same-origin",
        "user-agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Mobile Safari/537.36",
        "x-forwarded-for": "82.3.234.100",
        "x-forwarded-proto": "https",
        "x-real-ip": "82.3.234.100"
      },
      "cf": {
        "longitude": "-1.05280",
        "httpProtocol": "HTTP/3",
        "tlsCipher": "AEAD-AES128-GCM-SHA256",
        "continent": "EU",
        "asn": 5089,
        "clientAcceptEncoding": "gzip",
        "country": "GB",
        "colo": "LHR",
        "verifiedBotCategory": "",
        "tlsClientAuth": {
          "certIssuerDNLegacy": "",
          "certIssuerSKI": "",
          "certSubjectDNRFC2253": "",
          "certSubjectDNLegacy": "",
          "certFingerprintSHA256": "",
          "certNotBefore": "",
          "certSKI": "",
          "certSerial": "",
          "certIssuerDN": "",
          "certVerified": "NONE",
          "certNotAfter": "",
          "certSubjectDN": "",
          "certPresented": "0",
          "certRevoked": "0",
          "certIssuerSerial": "",
          "certIssuerDNRFC2253": "",
          "certFingerprintSHA1": ""
        },
        "tlsClientHelloLength": "",
        "tlsVersion": "TLSv1.3",
        "city": "Basingstoke",
        "timezone": "Europe/London",
        "tlsClientExtensionsSha1": "",
        "region": "England",
        "edgeRequestKeepAliveStatus": 1,
        "requestPriority": "",
        "latitude": "51.29110",
        "postalCode": "RG24",
        "tlsClientRandom": "",
        "regionCode": "ENG",
        "asOrganization": "Virgin Media",
        "pagesHostName": "carsearcher.pages.dev",
        "botManagement": {
          "corporateProxy": false,
          "verifiedBot": false,
          "jsDetection": {
            "passed": false
          },
          "staticResource": false,
          "detectionIds": {},
          "score": 99
        }
      }
    },
    "response": {
      "status": 500
    }
  },
  "id": 0
}

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.