TheCodedProf | 2a69bd9 | 2023-03-02 16:36:32 -0500 | [diff] [blame] | 1 | import Axios from 'axios'; |
| 2 | |
| 3 | const t = () => { return <></>} |
| 4 | export default t |
| 5 | export async function getServerSideProps(ctx) { |
| 6 | console.log(ctx.req.url) |
| 7 | if(!ctx.params.code) { |
| 8 | return { |
| 9 | redirect: { |
| 10 | destination: '/nucleus/transcript/about', |
| 11 | permanent: true |
| 12 | } |
| 13 | } |
| 14 | } |
| 15 | let code; |
| 16 | try { |
TheCodedProf | f054b8c | 2023-03-03 15:32:19 -0500 | [diff] [blame^] | 17 | code = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/transcript/${ctx.params.code}`)) |
TheCodedProf | 2a69bd9 | 2023-03-02 16:36:32 -0500 | [diff] [blame] | 18 | } catch (e) { |
| 19 | return { |
| 20 | redirect: { |
| 21 | destination: '/nucleus/transcript/invalid', |
| 22 | permanent: true |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | return { |
| 27 | redirect: { |
TheCodedProf | f054b8c | 2023-03-03 15:32:19 -0500 | [diff] [blame^] | 28 | destination: `http://${process.env.NUCLEUS_CALLBACK}/transcript/${ctx.params.code}`, |
TheCodedProf | 2a69bd9 | 2023-03-02 16:36:32 -0500 | [diff] [blame] | 29 | permanent: true |
| 30 | } |
| 31 | } |
| 32 | } |