Browse Source

fix: add missing protocol to cors urls

develop
Apostolos Fanakis 4 years ago
parent
commit
4444403324
  1. 3
      packages/concordia-app/src/constants/configuration/defaults.js
  2. 11
      packages/concordia-app/src/utils/drizzleUtils.js
  3. 2
      packages/concordia-contracts-provider/src/constants.js

3
packages/concordia-app/src/constants/configuration/defaults.js

@ -3,6 +3,9 @@ export const WEB3_PORT_DEFAULT = '8545';
export const WEB3_PORT_SOCKET_TIMEOUT_DEFAULT = 30000; export const WEB3_PORT_SOCKET_TIMEOUT_DEFAULT = 30000;
export const WEB3_PORT_SOCKET_CONNECT_MAX_ATTEMPTS_DEFAULT = 3; export const WEB3_PORT_SOCKET_CONNECT_MAX_ATTEMPTS_DEFAULT = 3;
export const REACT_APP_CONCORDIA_HOST_DEFAULT = '127.0.0.1';
export const REACT_APP_CONCORDIA_PORT_DEFAULT = '7000';
export const REACT_APP_RENDEZVOUS_HOST_DEFAULT = '127.0.0.1'; export const REACT_APP_RENDEZVOUS_HOST_DEFAULT = '127.0.0.1';
export const REACT_APP_RENDEZVOUS_PORT_DEFAULT = '9090'; export const REACT_APP_RENDEZVOUS_PORT_DEFAULT = '9090';

11
packages/concordia-app/src/utils/drizzleUtils.js

@ -1,6 +1,9 @@
import { import {
REACT_APP_CONCORDIA_HOST_DEFAULT,
REACT_APP_CONCORDIA_PORT_DEFAULT,
REACT_APP_CONTRACTS_SUPPLIER_HOST_DEFAULT, REACT_APP_CONTRACTS_SUPPLIER_HOST_DEFAULT,
REACT_APP_CONTRACTS_SUPPLIER_PORT_DEFAULT, REACT_APP_CONTRACTS_VERSION_HASH_DEFAULT, REACT_APP_CONTRACTS_SUPPLIER_PORT_DEFAULT,
REACT_APP_CONTRACTS_VERSION_HASH_DEFAULT,
} from '../constants/configuration/defaults'; } from '../constants/configuration/defaults';
import CONTRACTS from '../constants/contracts/ContractNames'; import CONTRACTS from '../constants/contracts/ContractNames';
@ -11,13 +14,15 @@ function getContractsDownloadRequest() {
|| REACT_APP_CONTRACTS_SUPPLIER_PORT_DEFAULT; || REACT_APP_CONTRACTS_SUPPLIER_PORT_DEFAULT;
const CONTRACTS_VERSION_HASH = process.env.REACT_APP_CONTRACTS_VERSION_HASH const CONTRACTS_VERSION_HASH = process.env.REACT_APP_CONTRACTS_VERSION_HASH
|| REACT_APP_CONTRACTS_VERSION_HASH_DEFAULT; || REACT_APP_CONTRACTS_VERSION_HASH_DEFAULT;
const HOST = process.env.REACT_APP_CONCORDIA_HOST || REACT_APP_CONCORDIA_HOST_DEFAULT;
const PORT = process.env.REACT_APP_CONCORDIA_PORT || REACT_APP_CONCORDIA_PORT_DEFAULT;
const xhrRequest = new XMLHttpRequest(); const xhrRequest = new XMLHttpRequest();
xhrRequest.open('GET', xhrRequest.open('GET',
`http://${CONTRACTS_SUPPLIER_HOST}:${CONTRACTS_SUPPLIER_PORT}/contracts/${CONTRACTS_VERSION_HASH}`, `http://${CONTRACTS_SUPPLIER_HOST}:${CONTRACTS_SUPPLIER_PORT}/contracts/${CONTRACTS_VERSION_HASH}`,
false); false);
xhrRequest.setRequestHeader('Access-Control-Allow-Origin', 'http://localhost:7000'); xhrRequest.setRequestHeader('Access-Control-Allow-Origin', `${HOST}:${PORT}`);
xhrRequest.setRequestHeader('Access-Control-Allow-Credentials', 'true'); xhrRequest.setRequestHeader('Access-Control-Allow-Credentials', 'true');
return xhrRequest; return xhrRequest;
@ -31,7 +36,7 @@ function validateRemoteContracts(remoteContracts) {
const contractsPresentStatus = CONTRACTS.map((contract) => ({ const contractsPresentStatus = CONTRACTS.map((contract) => ({
contract, contract,
present: remoteContracts.contains((remoteContract) => remoteContract.contractName === contract), present: remoteContracts.includes((remoteContract) => remoteContract.contractName === contract),
})); }));
if (contractsPresentStatus.reduce((accumulator, contract) => accumulator && contract.present, true)) { if (contractsPresentStatus.reduce((accumulator, contract) => accumulator && contract.present, true)) {

2
packages/concordia-contracts-provider/src/constants.js

@ -2,7 +2,7 @@ import path from 'path';
const PROVIDER_PORT = '8400'; const PROVIDER_PORT = '8400';
const UPLOAD_CONTRACTS_DIRECTORY = path.join(__dirname, '..', 'contracts-uploads'); const UPLOAD_CONTRACTS_DIRECTORY = path.join(__dirname, '..', 'contracts-uploads');
const CORS_ALLOWED_ORIGINS = ['localhost:7000', '127.0.0.1:7000']; const CORS_ALLOWED_ORIGINS = ['http://127.0.0.1:7000', 'http://localhost:7000'];
export default { export default {
port: PROVIDER_PORT, port: PROVIDER_PORT,

Loading…
Cancel
Save