Skip to content

Commit

Permalink
Add API envs
Browse files Browse the repository at this point in the history
  • Loading branch information
lanets committed Nov 30, 2019
1 parent 4cef017 commit bbcb986
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/ssr/SSR/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ class Server {

if (!api) {

const {
API_ENDPOINT = 'http://localhost:4000',
} = this.props;

api = new Prisma({
typeDefs: 'src/schema/generated/api.graphql',
endpoint: 'http://localhost:4000',
endpoint: API_ENDPOINT,
secret: 'mysecret123',
debug: false,
...props,
Expand Down Expand Up @@ -271,6 +275,7 @@ class Server {
props: {
rootSelector,
apolloCaches,
API_ENDPOINT = `${protocol}//${hostname}/api/`,
},
} = this;

Expand All @@ -282,7 +287,7 @@ class Server {
// Remember that this is the interface the SSR server will use to connect to the
// API server, so we need to ensure it isn't firewalled, etc
link: createHttpLink({
uri: `${protocol}//${hostname}/api/`,
uri: API_ENDPOINT,
credentials: 'same-origin',
headers: {
cookie: req.header('Cookie'),
Expand Down Expand Up @@ -662,7 +667,7 @@ class Server {
case "main":

return this.renderMainSitemap(req, res, uri);
// break;
// break;

default:
return this.renderRootSitemap(req, res, uri);
Expand Down
5 changes: 5 additions & 0 deletions src/ssr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,14 @@ const apolloCaches = {

};

const {
API_ENDPOINT = 'http://localhost:4000',
} = process.env;

let SSRmiddleware = new SSRmiddlewareClass({
apolloCaches,
rootSelector: "#root",
API_ENDPOINT,
}).middleware;

const ws = require('ws');
Expand Down

0 comments on commit bbcb986

Please sign in to comment.