Fetch cannot load MY_PATH

I'm currently stuck with this error cross all integration tests:
TypeError: Fetch API cannot load: <MY_PATH>
TypeError: Fetch API cannot load: <MY_PATH>
I'm using SELF
const res = await SELF.fetch(req.url, {
method: req.method,
headers: req.headers,
body: JSON.stringify(req.body),
});
const res = await SELF.fetch(req.url, {
method: req.method,
headers: req.headers,
body: JSON.stringify(req.body),
});
couldn't find anything via googling, has anyone encountered this too?
6 Replies
Jacob
Jacob•9mo ago
What does your vitest.config.ts look like?
chronark
chronarkOP•9mo ago
import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";

export default defineWorkersConfig({
test: {
dir: "./src/routes",
reporters: ["html", "verbose"],
outputFile: "./.vitest/html",
alias: {
"@/": new URL("./src/", import.meta.url).pathname,
},
pool: "@cloudflare/vitest-pool-workers",
poolOptions: {
singleWorker: true,
workers: {
wrangler: { configPath: "./wrangler.toml" },
},
},
testTimeout: 60_000,
teardownTimeout: 60_000,
},
});
import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";

export default defineWorkersConfig({
test: {
dir: "./src/routes",
reporters: ["html", "verbose"],
outputFile: "./.vitest/html",
alias: {
"@/": new URL("./src/", import.meta.url).pathname,
},
pool: "@cloudflare/vitest-pool-workers",
poolOptions: {
singleWorker: true,
workers: {
wrangler: { configPath: "./wrangler.toml" },
},
},
testTimeout: 60_000,
teardownTimeout: 60_000,
},
});
MrBBot
MrBBot•9mo ago
Is <MY_PATH> just a pathname or is it a full URL? You'll need to pass full URLs with protocols to SELF.fetch(). The protocol/host is ignored, but the value must be a valid URL.
chronark
chronarkOP•9mo ago
oh I just replaced it, it prints the correct paths
TypeError: Fetch API cannot load: /v1/apis.listKeys?apiId=test_2gV5Kah3DoEdrsmrKf3bnFc89AJZ
TypeError: Fetch API cannot load: /v1/apis.listKeys?apiId=test_2gV5Kah3DoEdrsmrKf3bnFc89AJZ
as example ok let me try full urls this used to work with unstable_dev, so I thought it would work here too
MrBBot
MrBBot•9mo ago
Yep, you'll need to make sure you're passing a full URL, something like https://placeholder/v1/apis/... Here, SELF is a service binding, which requires full URLs
chronark
chronarkOP•9mo ago
gotcha, that seems to work on to the next error 😅
Want results from more Discord servers?
Add your server