-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:tekdi/shiksha-admin into release-1.0.0
- Loading branch information
Showing
12 changed files
with
203 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
|
||
export const config = { | ||
api: { | ||
bodyParser: false, // Disable body parsing so we can handle it manually | ||
}, | ||
}; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
console.log('req.url ====>', req.url) | ||
if (req.method === 'POST') { | ||
try { | ||
// Create a new Headers object to ensure valid header types | ||
const headers = new Headers(); | ||
|
||
// Forward the incoming request headers, filtering out invalid headers | ||
for (const [key, value] of Object.entries(req.headers)) { | ||
// Exclude 'content-length' as it can cause issues | ||
if (key.toLowerCase() !== 'content-length') { | ||
headers.append(key, value as string); | ||
} | ||
} | ||
|
||
// Read the request body as a stream | ||
const body = await new Promise<Buffer>((resolve, reject) => { | ||
const chunks: Buffer[] = []; | ||
req.on('data', (chunk) => { | ||
chunks.push(Buffer.from(chunk)); | ||
}); | ||
req.on('end', () => { | ||
resolve(Buffer.concat(chunks)); | ||
}); | ||
req.on('error', (err) => { | ||
reject(err); | ||
}); | ||
}); | ||
|
||
// Forward the request to the middleware API | ||
const response = await fetch(`${process.env.WORKSPACE_BASE_URL}` + `${req.url}`, { | ||
method: 'POST', | ||
headers: headers, // Use the new Headers object | ||
body, // Pass the request body as a Buffer | ||
}); | ||
|
||
// Forward the middleware response back to the client | ||
const data = await response.json(); | ||
res.status(response.status).json(data); | ||
} catch (error) { | ||
console.error('Error proxying request:', error); | ||
res.status(500).json({ error: 'Internal Server Error' }); | ||
} | ||
} else { | ||
res.setHeader('Allow', ['POST']); | ||
res.status(405).end(`Method ${req.method} Not Allowed`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
import React from 'react' | ||
import dynamic from 'next/dynamic'; | ||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; | ||
|
||
import React from "react"; | ||
import dynamic from "next/dynamic"; | ||
import { serverSideTranslations } from "next-i18next/serverSideTranslations"; | ||
|
||
// @ts-ignore | ||
const Editors = dynamic(() => import('editor/Editor'), { ssr: false }); | ||
const Editors = dynamic(() => import("editor/Editor"), { ssr: false }); | ||
|
||
const Editor = () => { | ||
return ( | ||
<Editors /> | ||
) | ||
} | ||
|
||
export default Editor | ||
return <Editors />; | ||
}; | ||
|
||
export default Editor; | ||
|
||
export async function getStaticProps({ locale }: any) { | ||
return { | ||
props: { | ||
...(await serverSideTranslations(locale, ["common"])), | ||
}, | ||
}; | ||
} | ||
return { | ||
props: { | ||
noLayout: true, | ||
...(await serverSideTranslations(locale, ["common"])), | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react' | ||
import dynamic from 'next/dynamic'; | ||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; | ||
|
||
|
||
// @ts-ignore | ||
const UploadEditor = dynamic(() => import('editor/UploadEditor'), { ssr: false }); | ||
|
||
const Editor = () => { | ||
return ( | ||
<UploadEditor /> | ||
) | ||
} | ||
|
||
export default Editor | ||
|
||
export async function getStaticProps({ locale }: any) { | ||
return { | ||
props: { | ||
noLayout: true, | ||
...(await serverSideTranslations(locale, ["common"])), | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; | ||
import React from 'react' | ||
import dynamic from 'next/dynamic'; | ||
|
||
import { serverSideTranslations } from "next-i18next/serverSideTranslations"; | ||
import React from "react"; | ||
import dynamic from "next/dynamic"; | ||
|
||
// @ts-ignore | ||
const Content = dynamic(() => import('editor/Content'), { ssr: false }); | ||
const Content = dynamic(() => import("editor/Content"), { ssr: false }); | ||
|
||
const content = () => { | ||
return ( | ||
<Content /> | ||
) | ||
} | ||
|
||
export default content | ||
return <Content />; | ||
}; | ||
|
||
export default content; | ||
|
||
export async function getStaticProps({ locale }: any) { | ||
return { | ||
props: { | ||
noLayout: true, | ||
...(await serverSideTranslations(locale, ["common"])), | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; | ||
import React from 'react' | ||
import dynamic from 'next/dynamic'; | ||
|
||
import { serverSideTranslations } from "next-i18next/serverSideTranslations"; | ||
import React from "react"; | ||
import dynamic from "next/dynamic"; | ||
|
||
// @ts-ignore | ||
const Create = dynamic(() => import('editor/Create'), { ssr: false }); | ||
const Create = dynamic(() => import("editor/Create"), { ssr: false }); | ||
|
||
const create = () => { | ||
return ( | ||
<Create /> | ||
) | ||
} | ||
|
||
export default create | ||
return <Create />; | ||
}; | ||
|
||
export default create; | ||
|
||
export async function getStaticProps({ locale }: any) { | ||
return { | ||
props: { | ||
noLayout: true, | ||
...(await serverSideTranslations(locale, ["common"])), | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; | ||
import React from 'react' | ||
import dynamic from 'next/dynamic'; | ||
|
||
import { serverSideTranslations } from "next-i18next/serverSideTranslations"; | ||
import React from "react"; | ||
import dynamic from "next/dynamic"; | ||
|
||
// @ts-ignore | ||
const Draft = dynamic(() => import('editor/Draft'), { ssr: false }); | ||
const Draft = dynamic(() => import("editor/Draft"), { ssr: false }); | ||
|
||
const draft = () => { | ||
return ( | ||
<Draft /> | ||
) | ||
} | ||
|
||
export default draft | ||
return <Draft />; | ||
}; | ||
|
||
export default draft; | ||
|
||
export async function getStaticProps({ locale }: any) { | ||
return { | ||
props: { | ||
noLayout: true, | ||
...(await serverSideTranslations(locale, ["common"])), | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; | ||
import React from 'react' | ||
import dynamic from 'next/dynamic'; | ||
|
||
import { serverSideTranslations } from "next-i18next/serverSideTranslations"; | ||
import React from "react"; | ||
import dynamic from "next/dynamic"; | ||
|
||
// @ts-ignore | ||
const Publish = dynamic(() => import('editor/Publish'), { ssr: false }); | ||
const Publish = dynamic(() => import("editor/Publish"), { ssr: false }); | ||
|
||
const publish = () => { | ||
return ( | ||
<Publish /> | ||
) | ||
} | ||
|
||
export default publish | ||
return <Publish />; | ||
}; | ||
|
||
export default publish; | ||
|
||
export async function getStaticProps({ locale }: any) { | ||
return { | ||
props: { | ||
noLayout: true, | ||
...(await serverSideTranslations(locale, ["common"])), | ||
}, | ||
}; | ||
} | ||
} |
Oops, something went wrong.