next pages uses absolute url resolver to access api from getInitialProps

This commit is contained in:
tmshv committed 2019-10-11 23:14:01 +03:00
1 parent 28a4d05fe4
commit a502ddd4df
14 files changed
+37 -24

No files matched your search

+2 -2
View File
@@ -7,6 +7,7 @@ import menuModel from '../src/models/menu'
import { buildMenu } from '../src/lib/menu'
import { Meta } from '../src/components/Meta'
import { meta } from '../src/lib/meta'
import { createApiUrl } from '../src/next-lib'
const Index = (props) => (
<App
@@ -32,8 +33,7 @@ const Index = (props) => (
Index.getInitialProps = async (ctx) => {
const pageUrl = ctx.req.url
// // const pageUrl = '/neighbors/2018'
const apiUrl = `http://localhost:3000/api/page?page=${pageUrl}`
const res = await axios.get(apiUrl)
const res = await axios.get(createApiUrl(ctx.req, `/api/page?page=${pageUrl}`))
const page = res.data
const image = page.preview.artifacts.fb