universal-fs
Version:
Allows a client or server to access the file system in the current codebase or a different one.
16 lines (13 loc) • 330 B
text/typescript
import {isBrowser, isNode} from "browser-or-node";
import getCookie from "./getCookie";
import fs from "fs";
const getUrlSync = () => {
let url;
if (isBrowser) {
url = getCookie("universal-fs-url");
} else if (isNode) {
url = fs.readFileSync(".fs/url.txt", "utf8");
}
return url;
};
export default getUrlSync;