R
Railway11mo ago
Boxer

{"name":"TypeError","code":"ERR_INVALID_ARG_VALUE"} Calling API from another service in project

Hi, I'm trying to make a internal fetch API call to one of my services and it looks like it's erroring out with {"name":"TypeError","code":"ERR_INVALID_ARG_VALUE"} which is something I have not seen before. Code:
class SellerAmpClient {
private readonly baseURL: string = Bun.env.NOX_URL;

private async post<T, K>(url: string, data: K): Promise<T> {
try {
logger.info('here--url: ', `${this.baseURL}${url}`);
const response = await fetch(`${this.baseURL}${url}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
logger.info('here2', response);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}

return (await response.json()) as T;
} catch (error) {
logger.error(error);
throw error;
}
}
class SellerAmpClient {
private readonly baseURL: string = Bun.env.NOX_URL;

private async post<T, K>(url: string, data: K): Promise<T> {
try {
logger.info('here--url: ', `${this.baseURL}${url}`);
const response = await fetch(`${this.baseURL}${url}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
logger.info('here2', response);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}

return (await response.json()) as T;
} catch (error) {
logger.error(error);
throw error;
}
}
This is only happening in PROD since my local env does work, I'm sure it has something to do with the BaseURL which is basically: nox.railway.internal When checking the logs I see the first log I tested: [02:17:26.904] [info] here--url: nox.railway.internal/api/sellers/fba and then it fails. Am I missing something here?
Solution:
I WAS MISSING THE PORT
Jump to solution
6 Replies
Percy
Percy11mo ago
Project ID: f78d75b5-8972-4d61-8517-22bbccefb41e
Boxer
Boxer11mo ago
Do i need to add https:// to the beginning? nope, that didn't work
Brody
Brody11mo ago
please give this docs page a read https://docs.railway.app/guides/private-networking
Solution
Boxer
Boxer11mo ago
I WAS MISSING THE PORT
Boxer
Boxer11mo ago
sorry i read that page 10x but it was just the port and i completely missed it
Brody
Brody11mo ago
no worries
Want results from more Discord servers?
Add your server