lucaimbalzano
lucaimbalzano
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
and i was using them
30 replies
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
yes i am using them
30 replies
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
@Brody fixed, the problem were how i was pulling envs so the process is: - make sure it is taking the right .env file - add envs in your service in railway - add them also as ENV & ARG - depending on your webserver pull envs (process.env, import.meta.env,....) thank you brother
30 replies
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
Hey @Brody many thanks for your patience, i still have my envs undefined .. but you know what God is good also while my envs are undefined
30 replies
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
is this one:
import { defineConfig, loadEnv } from "vite";

export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
const BASE_API_URL = `${env.VITE_ENDPOINT_API_V1 ?? "http://localhost:3000"}`;
console.log(`vote.config.js::BASE_API_URL: ${BASE_API_URL}, mode: ${mode}`);
return {
server: {
origin: BASE_API_URL,
proxy: {
"/auth": {
target: BASE_API_URL,
secure: false,
changeOrigin: true,
logLevel: "debug",
},
"/house": {
target: BASE_API_URL,
secure: false,
changeOrigin: true,
logLevel: "debug",
},
.... All endpoints...
"/forgot-password/check": {
target: BASE_API_URL,
secure: false,
changeOrigin: true,
logLevel: "debug",
},
},
},
preview: {
port: 5173,
},
define: {
VITE_FIREBASE_API_KEY: JSON.stringify(env.VITE_FIREBASE_API_KEY),
VITE_FIREBASE_AUTHDOMAIN: JSON.stringify(env.VITE_FIREBASE_AUTHDOMAIN),
VITE_FIREBASE_PROJECT_ID: JSON.stringify(env.VITE_FIREBASE_PROJECT_ID),
VITE_FIREBASE_STORAGE_BUCKET: JSON.stringify(
env.VITE_FIREBASE_STORAGE_BUCKET
),
VITE_FIREBASE_MESSAGING_SENDER_ID: JSON.stringify(
env.VITE_FIREBASE_MESSAGING_SENDER_ID
),
VITE_FIREBASE_APP_ID: JSON.stringify(env.VITE_FIREBASE_APP_ID),
},
build: {
rollupOptions: {
assetsInclude: ["**/*.node"],
external: ["fsevents", "@swc/core", "@swc/wasm"],
},
},
};
});
import { defineConfig, loadEnv } from "vite";

export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
const BASE_API_URL = `${env.VITE_ENDPOINT_API_V1 ?? "http://localhost:3000"}`;
console.log(`vote.config.js::BASE_API_URL: ${BASE_API_URL}, mode: ${mode}`);
return {
server: {
origin: BASE_API_URL,
proxy: {
"/auth": {
target: BASE_API_URL,
secure: false,
changeOrigin: true,
logLevel: "debug",
},
"/house": {
target: BASE_API_URL,
secure: false,
changeOrigin: true,
logLevel: "debug",
},
.... All endpoints...
"/forgot-password/check": {
target: BASE_API_URL,
secure: false,
changeOrigin: true,
logLevel: "debug",
},
},
},
preview: {
port: 5173,
},
define: {
VITE_FIREBASE_API_KEY: JSON.stringify(env.VITE_FIREBASE_API_KEY),
VITE_FIREBASE_AUTHDOMAIN: JSON.stringify(env.VITE_FIREBASE_AUTHDOMAIN),
VITE_FIREBASE_PROJECT_ID: JSON.stringify(env.VITE_FIREBASE_PROJECT_ID),
VITE_FIREBASE_STORAGE_BUCKET: JSON.stringify(
env.VITE_FIREBASE_STORAGE_BUCKET
),
VITE_FIREBASE_MESSAGING_SENDER_ID: JSON.stringify(
env.VITE_FIREBASE_MESSAGING_SENDER_ID
),
VITE_FIREBASE_APP_ID: JSON.stringify(env.VITE_FIREBASE_APP_ID),
},
build: {
rollupOptions: {
assetsInclude: ["**/*.node"],
external: ["fsevents", "@swc/core", "@swc/wasm"],
},
},
};
});
i think it is sad because in localhost is working and in production not..
30 replies
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
@Brody and this have no sense:
import React, { useEffect, useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import { useDispatch, useSelector } from "react-redux";
import { useTranslation } from "react-i18next";

import {
signInStart,
signInSuccess,
signInFailure,
} from "../redux/user/userSlice";

import Spinner from "../components/Spinner";
import FloatingLabelInput from "../components/Input/FloatingLabelnput";

export default function SignIn() {
const BASE_URL = import.meta.VITE_ENDPOINT_API;
console.log(
`VITE CONFIG BASE URL: ${BASE_URL}`,
import.meta.env.VITE_FIREBASE_API_KEY_O,
import.meta.env.VITE_USER_QUEUE_REGISTRATION
);


...
import React, { useEffect, useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import { useDispatch, useSelector } from "react-redux";
import { useTranslation } from "react-i18next";

import {
signInStart,
signInSuccess,
signInFailure,
} from "../redux/user/userSlice";

import Spinner from "../components/Spinner";
import FloatingLabelInput from "../components/Input/FloatingLabelnput";

export default function SignIn() {
const BASE_URL = import.meta.VITE_ENDPOINT_API;
console.log(
`VITE CONFIG BASE URL: ${BASE_URL}`,
import.meta.env.VITE_FIREBASE_API_KEY_O,
import.meta.env.VITE_USER_QUEUE_REGISTRATION
);


...
when i run my docker container in localhost i see VITE_FIREBASE_API_KEY_O and VITE_USER_QUEUE_REGISTRATION but not my VITE_ENDPOINT_API (it is undefined)
30 replies
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
No description
30 replies
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
i have problems gettings envs.. and now i cannot reach the endpoind after deploy, i have 502 error here my actual Docker file
# Build Stage
FROM node:latest AS build

ENV NPM_CONFIG_UPDATE_NOTIFIER=false
ENV NPM_CONFIG_FUND=false

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . ./

# Define ARGs for each of your Firebase environment variables
ARG VITE_FIREBASE_API_KEY
ARG VITE_FIREBASE_AUTHDOMAIN
ARG VITE_FIREBASE_PROJECT_ID
ARG VITE_FIREBASE_STORAGE_BUCKET
ARG VITE_FIREBASE_MESSAGING_SENDER_ID
ARG VITE_FIREBASE_APP_ID
ARG VITE_ENDPOINT_API

# Pass ARG values to the build process
ENV VITE_FIREBASE_API_KEY=${VITE_FIREBASE_API_KEY}
ENV VITE_FIREBASE_AUTHDOMAIN=${VITE_FIREBASE_AUTHDOMAIN}
ENV VITE_FIREBASE_PROJECT_ID=${VITE_FIREBASE_PROJECT_ID}
ENV VITE_FIREBASE_STORAGE_BUCKET=${VITE_FIREBASE_STORAGE_BUCKET}
ENV VITE_FIREBASE_MESSAGING_SENDER_ID=${VITE_FIREBASE_MESSAGING_SENDER_ID}
ENV VITE_FIREBASE_APP_ID=${VITE_FIREBASE_APP_ID}
ENV VITE_ENDPOINT_API=${VITE_ENDPOINT_API}

RUN npm run build

# Serve Stage
FROM caddy:latest

WORKDIR /app

COPY Caddyfile /etc/caddy/Caddyfile

# Copy the build output from the build stage to the serve stage
COPY --from=build /app/dist /app/dist

EXPOSE 5173

CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
# Build Stage
FROM node:latest AS build

ENV NPM_CONFIG_UPDATE_NOTIFIER=false
ENV NPM_CONFIG_FUND=false

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . ./

# Define ARGs for each of your Firebase environment variables
ARG VITE_FIREBASE_API_KEY
ARG VITE_FIREBASE_AUTHDOMAIN
ARG VITE_FIREBASE_PROJECT_ID
ARG VITE_FIREBASE_STORAGE_BUCKET
ARG VITE_FIREBASE_MESSAGING_SENDER_ID
ARG VITE_FIREBASE_APP_ID
ARG VITE_ENDPOINT_API

# Pass ARG values to the build process
ENV VITE_FIREBASE_API_KEY=${VITE_FIREBASE_API_KEY}
ENV VITE_FIREBASE_AUTHDOMAIN=${VITE_FIREBASE_AUTHDOMAIN}
ENV VITE_FIREBASE_PROJECT_ID=${VITE_FIREBASE_PROJECT_ID}
ENV VITE_FIREBASE_STORAGE_BUCKET=${VITE_FIREBASE_STORAGE_BUCKET}
ENV VITE_FIREBASE_MESSAGING_SENDER_ID=${VITE_FIREBASE_MESSAGING_SENDER_ID}
ENV VITE_FIREBASE_APP_ID=${VITE_FIREBASE_APP_ID}
ENV VITE_ENDPOINT_API=${VITE_ENDPOINT_API}

RUN npm run build

# Serve Stage
FROM caddy:latest

WORKDIR /app

COPY Caddyfile /etc/caddy/Caddyfile

# Copy the build output from the build stage to the serve stage
COPY --from=build /app/dist /app/dist

EXPOSE 5173

CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
30 replies
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
these endpoints:
import { defineConfig, loadEnv } from "vite";

export default defineConfig(({ mode }) => {
// Load environment variables based on the current mode
const env = loadEnv(mode, process.cwd());

// Define your BASE_API_URL using the environment variable or fallback to localhost
const BASE_API_URL = `${env.VITE_ENDPOINT_API_V1 ?? "http://localhost:3000"}`;

return {
server: {
origin: BASE_API_URL,
proxy: {
"/auth": {
target: BASE_API_URL,
secure: false,
changeOrigin: true,
logLevel: "debug",
},
// ... other proxies
},
},
preview: {
port: 3000,
},
define: {
VITE_FIREBASE_API_KEY: JSON.stringify(env.VITE_FIREBASE_API_KEY),
VITE_FIREBASE_AUTHDOMAIN: JSON.stringify(env.VITE_FIREBASE_AUTHDOMAIN),
VITE_FIREBASE_PROJECT_ID: JSON.stringify(env.VITE_FIREBASE_PROJECT_ID),
VITE_FIREBASE_STORAGE_BUCKET: JSON.stringify(
env.VITE_FIREBASE_STORAGE_BUCKET
),
VITE_FIREBASE_MESSAGING_SENDER_ID: JSON.stringify(
env.VITE_FIREBASE_MESSAGING_SENDER_ID
),
VITE_FIREBASE_APP_ID: JSON.stringify(env.VITE_FIREBASE_APP_ID),
},
build: {
rollupOptions: {
assetsInclude: ["**/*.node"],
external: ["fsevents", "@swc/core", "@swc/wasm"],
},
},
};
});

}
import { defineConfig, loadEnv } from "vite";

export default defineConfig(({ mode }) => {
// Load environment variables based on the current mode
const env = loadEnv(mode, process.cwd());

// Define your BASE_API_URL using the environment variable or fallback to localhost
const BASE_API_URL = `${env.VITE_ENDPOINT_API_V1 ?? "http://localhost:3000"}`;

return {
server: {
origin: BASE_API_URL,
proxy: {
"/auth": {
target: BASE_API_URL,
secure: false,
changeOrigin: true,
logLevel: "debug",
},
// ... other proxies
},
},
preview: {
port: 3000,
},
define: {
VITE_FIREBASE_API_KEY: JSON.stringify(env.VITE_FIREBASE_API_KEY),
VITE_FIREBASE_AUTHDOMAIN: JSON.stringify(env.VITE_FIREBASE_AUTHDOMAIN),
VITE_FIREBASE_PROJECT_ID: JSON.stringify(env.VITE_FIREBASE_PROJECT_ID),
VITE_FIREBASE_STORAGE_BUCKET: JSON.stringify(
env.VITE_FIREBASE_STORAGE_BUCKET
),
VITE_FIREBASE_MESSAGING_SENDER_ID: JSON.stringify(
env.VITE_FIREBASE_MESSAGING_SENDER_ID
),
VITE_FIREBASE_APP_ID: JSON.stringify(env.VITE_FIREBASE_APP_ID),
},
build: {
rollupOptions: {
assetsInclude: ["**/*.node"],
external: ["fsevents", "@swc/core", "@swc/wasm"],
},
},
};
});

}
in this case it understand base_url/auth
30 replies
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
hey @Brody now is up, i think i made a success deploy with caddy i had problem to understand on how i need to place the endpoints as i did in my vite.config.js before
30 replies
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
it is failing because i am trying to fix that errors
30 replies
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
do you think i need to rewrite everything?
30 replies
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
let is swap
30 replies
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
okok, i just posted here because i saw quick answers, any help with that thread?
30 replies
RRailway
Created by lucaimbalzano on 9/3/2024 in #✋|help
env vite reactjs
0bebe0c6-57e2-4755-93c3-ce48f433731b
30 replies