a year ago
I declared a internal path to my pocketbase api using following:
const pb = new PocketBase(process.env.INTERNALAPIPATH);
and as INTERNALAPIPATH I set following content in variables:
http://${{api.RAILWAYPRIVATEDOMAIN}}:${{api.PORT}}
following error occurs in build time:
12 15.84 node:internal/event_target:1033
12 15.84 process.nextTick(() => { throw err; });
12 15.84 ^
12 15.85 ClientResponseError 0: Something went wrong while processing your request.
12 15.85 at file:///app/node_modules/pocketbase/dist/pocketbase.es.mjs:1:32313
12 15.85 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
12 15.85 at async file:///app/.svelte-kit/output/server/entries/pages/_layout.server.ts.js:3:1
12 15.85 Emitted 'error' event on Worker instance at:
12 15.85 at kOnErrorMessage
12 15.85 at kOnMessage
12 15.85 at MessagePort. (node:internal/worker:212:57)
12 15.85 at nodejs.internal.kHybridDispatch
12 15.85 at exports.emitMessage (node:internal/per_context/messageport:23:28) {
12 15.85 url: '',
12 15.85 status: 0,
12 15.85 response: {},
12 15.85 isAbort: false,
12 15.85 originalError: TypeError: fetch failed
12 15.85 at Object.fetch (node:internal/deps/undici/undici:11372:11)
12 15.85 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
12 15.85 at async file:///app/.svelte-kit/output/server/entries/pages/_layout.server.ts.js:3:1 {
12 15.85 [cause]: Error: getaddrinfo ENOTFOUND pocketbase.railway.internal
12 15.85 at GetAddrInfoReqWrap.onlookup as oncomplete
12 15.85 }
12 15.85 }
12 15.85
12 15.85 Node.js v18.18.2
12 15.90 error: script "build" exited with code 1 (SIGHUP)
12 ERROR: process "/bin/bash -ol pipefail -c bun run build" did not complete successfully: exit code: 1
> [stage-0 8/10] RUN --mount=type=cache,id=s/ee3af10c-0dbd-426b-b86a-ad55d6f630fe-nodemodules/cache,target=/app/nodemodules/.cache bun run build:
15.85 at Object.fetch (node:internal/deps/undici/undici:11372:11)
15.85 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
15.85 at async file:///app/.svelte-kit/output/server/entries/pages/_layout.server.ts.js:3:1 {
15.85 [cause]: Error: getaddrinfo ENOTFOUND pocketbase.railway.internal
15.85 at GetAddrInfoReqWrap.onlookup as oncomplete
15.85 }
15.85 }
15.85
15.85 Node.js v18.18.2
15.90 error: script "build" exited with code 1 (SIGHUP)
> ⓘ Deployment information is only viewable by Project members and Railway admins.
4 Replies
a year ago
Fixed the error by defaulting to https://${{pocketbase.RAILWAYPUBLICDOMAIN}} then using hooks.server.ts to change the behaviour in runtime:
import type { HandleFetch } from '@sveltejs/kit';
export const handleFetch: HandleFetch = async ({ request, fetch }) => {
if (request.url.startsWith(process.env.APIPATH)) { request = new Request( request.url.replace(process.env.APIPATH, process.env.INTERNALAPIPATH),
request,
);
}
return fetch(request);
};
Status changed to Solved railway[bot] • about 1 year ago
a year ago
yes sure thats the case. corrected my reply