budivoogt
PROOP
10 months ago
I have a SvelteKit app which uses the Railway injected PORT of 8080.
I have a Railway function which is triggered on a chron schedule. It works perfectly when I use the PUBLIC_URL of my SvelteKit app service, but not when using the private networking URL. I am using http:// and :8080 on that private networking URL, but I keep getting a connection refused error:
Error checking notifications: error: Unable to connect. Is the computer able to access the url?
path: "http://ohmydocs.railway.internal:8080/api/notifications/check-due";,
errno: 0,
code: "ConnectionRefused"Any idea how to resolve? Could this be related to the new Metal servers? Both are deployed on Metal Amsterdam.
Function code:
const BEARER_TOKEN = Bun.env.ADMIN_BEARER_TOKEN;
// CREATE PRIVATE ENDPOINT
const OHMYDOCS_PRIVATE_URL =
`http://` + Bun.env.OHMYDOCS_PRIVATE_URL + `:` + Bun.env.OHMYDOCS_PORT;
const OHMYDOCS_PRIVATE_ENDPOINT = new URL(
"/api/notifications/check-due",
OHMYDOCS_PRIVATE_URL
);
// CREATE PUBLIC ENDPOINT
const OHMYDOCS_PUBLIC_URL = `https://` + Bun.env.OHMYDOCS_PUBLIC_URL;
const OHMYDOCS_PUBLIC_ENDPOINT = new URL(
"/api/notifications/check-due",
OHMYDOCS_PUBLIC_URL
);
async function checkNotificationsDue() {
try {
// NOW USING PUBLIC ENDPOINT
const response = await fetch(OHMYDOCS_PUBLIC_ENDPOINT, {
method: "POST",
headers: {
Authorization: `Bearer ${BEARER_TOKEN}`,
"Content-Type": "application/json",
},
});
if (!response.ok) {
console.error(`Failed to check notifications: ${response.status}`);
}
console.log(`notificationsDue endpoint hit`);
} catch (error) {
console.error("Error checking notifications:", error);
}
}
checkNotificationsDue();2 Replies
budivoogt
PROOP
10 months ago
1fb7b057-4030-4839-a1f8-68638ed52a4e
brody
EMPLOYEE
10 months ago
is the application listening on IPv6? since the private network is IPv6 only.