Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
fix(runTime): use relative urls for defaulted report variables
Browse files Browse the repository at this point in the history
  • Loading branch information
smackfu authored and 10xLaCroixDrinker committed Nov 29, 2023
1 parent d3df6d5 commit 059df73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions __tests__/server/config/env/runTime.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,7 @@ describe('runTime', () => {

it('has a default value for development', () => {
process.env.NODE_ENV = 'development';
expect(clientReportingUrl.defaultValue()).toBeDefined();
expect(clientReportingUrl.defaultValue()).toMatch(/^https?:\/\//);
expect(clientReportingUrl.defaultValue()).toBe('/_/report/errors');
});

it('has no default value for production', () => {
Expand All @@ -372,8 +371,7 @@ describe('runTime', () => {

it('has a default value for development', () => {
process.env.NODE_ENV = 'development';
expect(clientCSPReportingUrl.defaultValue()).toBeDefined();
expect(clientCSPReportingUrl.defaultValue()).toMatch(/^https?:\/\//);
expect(clientCSPReportingUrl.defaultValue()).toBe('/_/report/security/csp-violation');
});

it('has no default value for production', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/server/config/env/runTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ const runTime = [
{
name: 'ONE_CLIENT_REPORTING_URL',
defaultValue: () => (process.env.NODE_ENV === 'development'
? `http://${ip}:${process.env.HTTP_PORT}/_/report/errors`
? '/_/report/errors'
: undefined),
validate: isFetchableUrlInBrowser,
},
// where to send/report csp violations
{
name: 'ONE_CLIENT_CSP_REPORTING_URL',
defaultValue: () => (process.env.NODE_ENV === 'development'
? `http://${ip}:${process.env.HTTP_PORT}/_/report/security/csp-violation`
? '/_/report/security/csp-violation'
: undefined),
validate: isFetchableUrlInBrowser,
},
Expand Down

0 comments on commit 059df73

Please sign in to comment.