diff --git a/.env b/.env
new file mode 100644
index 0000000..407f9a9
--- /dev/null
+++ b/.env
@@ -0,0 +1,6 @@
+NEXT_PUBLIC_API_PATTERN=/api
+
+NEXT_PUBLIC_CONTENT_URL=/content/torrent
+NEXT_PUBLIC_FRAGMENT_URL=/content/audio
+NEXT_PUBLIC_COVER_FULL_URL=/content/images/cover/full_size
+NEXT_PUBLIC_COVER_PREVIEW_URL=/content/images/cover/preview
\ No newline at end of file
diff --git a/.env.development b/.env.development
index 5dd0555..7a2278a 100644
--- a/.env.development
+++ b/.env.development
@@ -1,5 +1,9 @@
-NEXT_PUBLIC_BASE_URL=http://127.0.0.1:3000/api
-NEXT_PUBLIC_CONTENT_URL=http://127.0.0.1:8000/content/torrent
-NEXT_PUBLIC_FRAGMENT_URL=http://127.0.0.1:8000/content/audio
-NEXT_PUBLIC_COVER_FULL_URL=http://127.0.0.1:8000/content/images/cover/full_size
-NEXT_PUBLIC_COVER_PREVIEW_URL=http://127.0.0.1:8000/content/images/cover/preview
\ No newline at end of file
+BACKEND_PROTOCOL=http
+BACKEND_DOMAIN=127.0.0.1
+BACKEND_PORT=8000
+
+BASE_PROTOCOL=http
+BASE_DOMAIN=127.0.0.1
+BASE_PORT=3000
+
+NEXT_PUBLIC_BASE_URL=http://127.0.0.1:3000
\ No newline at end of file
diff --git a/next.config.mjs b/next.config.mjs
index ea8e890..3bc3ee1 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -1,21 +1,20 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
async rewrites() {
- return process.env.NODE_ENV == "development"
- ? [
- {
- source: "/api/:path*",
- destination: "http://127.0.0.1:8000/:path*",
- },
- ]
- : [];
+ return [
+ {
+ source: "/api/:path*",
+ destination: `${process.env.BACKEND_PROTOCOL}://`+
+ `${process.env.BACKEND_DOMAIN}:${process.env.BACKEND_PORT}/:path*`,
+ }
+ ]
},
images: {
remotePatterns: [
{
- protocol: "http",
- hostname: "127.0.0.1",
- port: "8000",
+ protocol: process.env.BASE_PROTOCOL,
+ hostname: process.env.BASE_DOMAIN,
+ port: process.env.BASE_PORT,
},
],
},
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 11e462a..70d4cda 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -11,39 +11,47 @@ export const metadata: Metadata = {
};
export default async function Home() {
- const cards: { [k in SectionType]?: ItemCardType[] | null } = {};
- await Promise.all(
- SectionService.sections.map(async (section) => {
- cards[section] = await ItemService.itemsConfiguration[
- SectionService.sectionsConfiguration[section].itemType
- ].service.GetCards();
- })
+ const requests = SectionService.sections.map((section) =>
+ ItemService.itemsConfiguration[
+ SectionService.sectionsConfiguration[section].itemType
+ ].service.GetCards()
+ );
+ const data = await Promise.all(requests);
+
+ const cards = await SectionService.sections.reduce(
+ (cards, section, i) => ({
+ ...cards,
+ [section]: data[i],
+ }),
+ {} as { [k in SectionType]: ItemCardType[] | null }
);
return (
<>
- {SectionService.sections.map((section) => (
-
- {cards[section] && cards[section].length > 0 && (
-
- {cards[section].map((card) => (
-
- ))}
-
- )}
-
- ))}
+ {cards &&
+ SectionService.sections.map((section, i) => (
+
+ {cards[section] && (
+
+ {cards[section]?.map((card) => (
+
+ ))}
+
+ )}
+
+ ))}
>
);
}
diff --git a/src/shared/ui/image.tsx b/src/shared/ui/image.tsx
index 32f78d8..d270ba0 100644
--- a/src/shared/ui/image.tsx
+++ b/src/shared/ui/image.tsx
@@ -21,6 +21,9 @@ export const Img = ({
{
if (r && r.ok) return r;
else throw Error("Response ok = false");
diff --git a/src/widgets/itemInfo/itemFragment.tsx b/src/widgets/itemInfo/itemFragment.tsx
index 81e8dd8..09ae02c 100644
--- a/src/widgets/itemInfo/itemFragment.tsx
+++ b/src/widgets/itemInfo/itemFragment.tsx
@@ -62,6 +62,9 @@ export const ItemFragment = ({
controlsList="nodownload"
typeof="audio/mpeg"
src={
+ "" +
+ process.env.NEXT_PUBLIC_BASE_URL +
+ process.env.NEXT_PUBLIC_API_PATTERN +
process.env.NEXT_PUBLIC_FRAGMENT_URL +
"/" +
(watched_fragment ?? "")
diff --git a/src/widgets/itemInfo/itemTorrent.tsx b/src/widgets/itemInfo/itemTorrent.tsx
index 033d935..e8d73a6 100644
--- a/src/widgets/itemInfo/itemTorrent.tsx
+++ b/src/widgets/itemInfo/itemTorrent.tsx
@@ -67,7 +67,12 @@ export const ItemTorrent = ({