Variable seems to not be pasing into nextjs application
joro550
HOBBYOP
a year ago
Hey there, I have setup a simple application with a backend/frontend/database
I have set the variable for my front end to be RAILWAY_PRIVATE_DOMAIN it is called NEXT_PUBLIC_BACKEND_URL I read another thread saying that I had to add an arg into my dockerfile so I did that:
ARG NEXT_PUBLIC_BACKEND_URL
Getting the variable:
"use client";
import { Weather } from "./podcast-models";
export default class PodcastService {
private _baseUrl: string;
constructor() {
this._baseUrl = process.env.NEXT_PUBLIC_BACKEND_URL ?? "";
}
public async getWeather(): Promise<Weather[]> {
let response = await fetch(`${this._baseUrl}/weather`);
return (await response.json()) as Weather[];
}
}but when the request is sent the url is set to the frontend servive (which probably means that its defaulting to empty string) any help would be appreciated
1 Replies