Fix some errors running behind a proxy.
This commit is contained in:
parent
b3714c90c8
commit
32de1f0ac2
@ -8,12 +8,15 @@ import { InMemoryCache } from 'apollo-cache-inmemory';
|
|||||||
|
|
||||||
import { createResolvers } from './resolvers';
|
import { createResolvers } from './resolvers';
|
||||||
|
|
||||||
const defaultServer = `${window.location.origin}/${window.location.pathname}`
|
const defaultServer = `${window.location.origin}`;
|
||||||
|
|
||||||
export const graphqlApi = config => {
|
export const graphqlApi = config => {
|
||||||
const { api: { server = defaultServer, path = '/api/graphql' } } = config;
|
const { api: { server = defaultServer, port = '', path = '/api' } } = config;
|
||||||
|
let base = server;
|
||||||
return `${server}${path}`;
|
if (port) {
|
||||||
|
base = `${base}:${port}`;
|
||||||
|
}
|
||||||
|
return `${base}${path}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import get from 'lodash.get';
|
||||||
import Link from '@material-ui/core/Link';
|
import Link from '@material-ui/core/Link';
|
||||||
|
|
||||||
import { getServiceUrl } from '../util/config';
|
import { getServiceUrl } from '../util/config';
|
||||||
@ -12,11 +13,12 @@ const getAppUrl = (config, { name, version }) => {
|
|||||||
const pathComponents = [base];
|
const pathComponents = [base];
|
||||||
|
|
||||||
// TODO(burdon): Fix.
|
// TODO(burdon): Fix.
|
||||||
// `wire app serve` expects the /wrn/ prefix.
|
// `wire app serve` expects the /app/ prefix.
|
||||||
// That is OK in the production config where we can make it part of the the route,
|
// That is OK in the production config where we can make it part of the the route,
|
||||||
// but in development it must be prepended since we don't want to make it part of services.app.server.
|
// but in development it must be prepended since we don't want to make it part of services.app.server.
|
||||||
if (!base.startsWith(`/${config.services.app.prefix}`) && !base.endsWith(`/${config.services.app.prefix}`)) {
|
const prefix = get(config, 'services.app.prefix');
|
||||||
pathComponents.push(config.services.app.prefix.substring(1));
|
if (prefix && !base.startsWith(`/${prefix}`) && !base.endsWith(`/${prefix}`)) {
|
||||||
|
pathComponents.push(prefix.substring(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version) {
|
if (version) {
|
||||||
|
Loading…
Reference in New Issue
Block a user