2 years ago
I declared a internal path to my pocketbase api using following:
const pb = new PocketBase(process.env.INTERNAL_API_PATH);
and as INTERNAL_API_PATH I set following content in variables:
http://${{api.RAILWAY_PRIVATE_DOMAIN}}:${{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] (node:internal/worker:300:10)
#12 15.85 at [kOnMessage] (node:internal/worker:311:37)
#12 15.85 at MessagePort. (node:internal/worker:212:57)
#12 15.85 at [nodejs.internal.kHybridDispatch] (node:internal/event_target:757:20)
#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] (node:dns:108:26)
#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-node_modules/cache,target=/app/node_modules/.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] (node:dns:108:26)
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
2 years ago
Fixed the error by defaulting to https://${{pocketbase.RAILWAY_PUBLIC_DOMAIN}} 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.API_PATH)) {
request = new Request(
request.url.replace(process.env.API_PATH, process.env.INTERNAL_API_PATH),
request,
);
}
return fetch(request);
};
Status changed to Solved Railway • about 2 years ago
2 years ago
yes sure thats the case. corrected my reply