Add .evn settings, StyledComponent Server Side Setting

This commit is contained in:
HeesungB 2022-12-17 00:36:07 +09:00
parent dd8f108cb7
commit 0eba7c4cf9
3 changed files with 34 additions and 15 deletions

View File

@ -2,13 +2,17 @@ export const MainChainId = "osmo-test-4";
export const REFERRAL_KEY = "icns-referral";
export const RPC_URL = "https://rpc.testnet.osmosis.zone";
export const REST_URL = "https://lcd.testnet.osmosis.zone";
export const RPC_URL =
process.env.OSMOSIS_RPC_URL ?? "https://rpc.testnet.osmosis.zone";
export const REST_URL =
process.env.OSMOSIS_REST_URL ?? "https://lcd.testnet.osmosis.zone";
// TODO: .evn에 없으면 디폴트값 설정
export const NAME_NFT_ADDRESS =
process.env.ICNS_NAME_NFT_CONTRACT_ADDRESS ??
"osmo1xahnjn872smah6xle8n3z5a5teqq390qr959l805mkuw0kcy8g5smtdagg";
export const REGISTRAR_ADDRESS =
process.env.ICNS_REGISTRAR_CONTRACT_ADDRESS ??
"osmo1npn97g7hsgqlp70rw8nhd7c7vyvkukv9x0n25sn4fk5mgcjlz4gq9zlgf3";
export const RESOLVER_ADDRESS =
process.env.ICNS_RESOLVER_CONTRACT_ADDRESS ??
"osmo1002awr7frr9wk44lc3vfzt0d2w6vz5z03ql6fszjsjy8vdcvk0sskruz3c";

View File

@ -5,24 +5,39 @@ import Document, {
Main,
NextScript,
} from "next/document";
import { ServerStyleSheet } from "styled-components";
class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const sheet = new ServerStyleSheet();
const originalRenderPage = ctx.renderPage;
// Run the React rendering logic synchronously
ctx.renderPage = () =>
originalRenderPage({
// Useful for wrapping the whole react tree
enhanceApp: (App) => App,
// Useful for wrapping in a per-page basis
enhanceComponent: (Component) => Component,
});
try {
// Run the React rendering logic synchronously
ctx.renderPage = () =>
originalRenderPage({
// Useful for wrapping the whole react tree
enhanceApp: (App) => (props) =>
sheet.collectStyles(<App {...props} />),
// Useful for wrapping in a per-page basis
enhanceComponent: (Component) => Component,
});
// Run the parent `getInitialProps`, it now includes the custom `renderPage`
const initialProps = await Document.getInitialProps(ctx);
// Run the parent `getInitialProps`, it now includes the custom `renderPage`
const initialProps = await Document.getInitialProps(ctx);
return initialProps;
return {
...initialProps,
styles: (
<div>
{initialProps.styles}
{sheet.getStyleElement()}
</div>
),
};
} finally {
sheet.seal();
}
}
render() {

View File

@ -1,7 +1,7 @@
import { withIronSessionApiRoute } from "iron-session/next";
import type { NextApiRequest, NextApiResponse } from "next";
import { ironOptions } from "../../iron.config";
import { IcnsVerificationResponse } from "../../types/api-response";
import { IcnsVerificationResponse } from "../../types";
import { request } from "../../utils/url";
export default withIronSessionApiRoute(async function handler(