Even though i have used a 'use server' directive on my server file the file somehow is ending up on the client side of the app, that is, it is showing up in the browser.
"use server";
import { productListSorter } from "@/util/utility";
import oracledb from "oracledb";
let connect = await oracledb.getConnection({
user: "student",
password: "studentpassword",
connectString: "localhost:1521/XEPDB1",
});
export const getAllProducts = async () => {
const products = await connect.execute(`SELECT * FROM products`);
return productListSorter(products.rows);
};
i was expecting it to not show up on the client side and it is doing so therefore exposing my database credentials
Server componentes are rendered in the server, and its result is streamed to the browser, but your server component code is not present in the client bundle, so your credentials are safe.
This blog post states:
Also in the docs:
But it is recommended to use a DAL:
A third-party blog post about RSC: