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

fix(conditionallyAllowCors): nested array of cors origins #14

Merged
merged 2 commits into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ import { setRenderPartialOnly } from '@americanexpress/one-app-ducks';
dispatch(setRenderPartialOnly(true));
```

[CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) is enabled for partial requests and by default there are no allowed origins. Add origins in the root module [corsOrigins](#corsorigins) in the [appConfig](#app-configuration)

See the [`Partial` component](./prod-sample/sample-modules/frank-lloyd-root/0.0.2/src/components/Partial.jsx)
in the `frank-lloyd-root` module for an example implementation.

Expand Down Expand Up @@ -551,8 +553,8 @@ security and bundle size considerations.

##### `provideStateConfig`
**Module Type**
* ✅ Root Module
* 🚫 Child Module
* ✅ Root Module
* 🚫 Child Module

**Shape**
```js
Expand Down Expand Up @@ -610,8 +612,8 @@ Based on `environmentLevel`, the String values are injected into the global [`co

##### `csp`
**Module Type**
* ✅ Root Module
* 🚫 Child Module
* ✅ Root Module
* 🚫 Child Module

⚠️ Required Directive

Expand All @@ -636,8 +638,8 @@ The `csp` static `String` should be a valid [Content Security Policy (CSP)](http

##### `corsOrigins`
**Module Type**
* ✅ Root Module
* 🚫 Child Module
* ✅ Root Module
* 🚫 Child Module

> 👮**Security Feature**: Limits the reachable origins for fetching data and assets.

Expand All @@ -661,8 +663,8 @@ In practice, this allows POST requests from given origins to return partially re

##### `configureRequestLog`
**Module Type**
* ✅ Root Module
* 🚫 Child Module
* ✅ Root Module
* 🚫 Child Module

**Shape**
```js
Expand Down Expand Up @@ -715,8 +717,8 @@ The `configureRequestLog` directive accepts a callback that takes Express's `req

##### `extendSafeRequestRestrictedAttributes`
**Module Type**
* ✅ Root Module
* 🚫 Child Module
* ✅ Root Module
* 🚫 Child Module

> 👮**Security Feature**: Limits headers and cookies from being passed to Redux's initial state.

Expand All @@ -741,8 +743,8 @@ The `extendSafeRequestRestrictedAttributes` directive accepts a list of cookie n

##### `createSsrFetch`
**Module Type**
* ✅ Root Module
* 🚫 Child Module
* ✅ Root Module
* 🚫 Child Module

**Shape**
```js
Expand All @@ -754,9 +756,9 @@ if (!global.BROWSER) {
}) => (fetch) => (fetchUrl, fetchOpts) => Promise,
};
}
```
```

`createSsrFetch` allows for customizing the fetch client used in `one-app` to perform server-side requests.
`createSsrFetch` allows for customizing the fetch client used in `one-app` to perform server-side requests.

For example, you may wish to forward cookies or headers from the initial page load request to all the requisite SSR API requests.

Expand All @@ -767,8 +769,8 @@ For example, you may wish to forward cookies or headers from the initial page lo

##### `validateStateConfig`
**Module Type**
* 🚫 Root Module
* ✅ Child Module
* 🚫 Root Module
* ✅ Child Module

**Shape**
```js
Expand Down Expand Up @@ -804,8 +806,8 @@ If an `Error` is thrown, the Server will fail to startup or if already running w

##### `requiredSafeRequestRestrictedAttributes`
**Module Type**
* 🚫 Root Module
* ✅ Child Module
* 🚫 Root Module
* ✅ Child Module

> 👮**Security Feature**: Limits headers and cookies from being passed to Redux's initial state.

Expand All @@ -831,8 +833,8 @@ If an `Error` is thrown due to missing required cookies or headers, the Server w

##### `appCompatibility`
**Module Type**
* ✅ Root Module
* ✅ Child Module
* ✅ Root Module
* ✅ Child Module

**Shape**
```js
Expand Down
2 changes: 1 addition & 1 deletion src/server/middleware/conditionallyAllowCors.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const corsOptions = {
export const setCorsOrigins = (newCorsOrigins = []) => {
corsOptions.origin = process.env.NODE_ENV === 'development'
? [...newCorsOrigins, devOrigin]
: [newCorsOrigins];
: newCorsOrigins;
};

setCorsOrigins();
Expand Down