Skip to content

Commit

Permalink
Merge pull request #13 from VeliovGroup/cordova-1
Browse files Browse the repository at this point in the history
🚢 v2.4.1
  • Loading branch information
dr-dimitru authored Sep 29, 2019
2 parents 417bda1 + 4c6ac19 commit 722c07b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .versions
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ meteor add ostrio:cookies
import { Cookies } from 'meteor/ostrio:cookies';
```

## API:
## FAQ:

- __Cookies are missing on Server__ — In 99% cases it's caused by Meteor's `webapp` http server callback-chain disorder. Make sure `new Cookies()` is called before *Routes* are registered. Routing packages usually take care of `*` (e.g. catch-all or 404) route, not passing request further to callback-chain. And as freshly installed package it would be placed at the end of `.meteor/packages` file, where list-order matters. We recommend to place `ostrio:cookies` package above all community packages in `.meteor/packages` list.

__Note:__ On a server, cookies will be set __only__ after headers are sent (on next route or page reload). To send cookies from *Client* to *Server* without a page reload use `send()` method.
## API:

__Server Usage Note:__ On a server Cookies implemented as a middleware. To get access to current user's cookies use `req.Cookies` instance. For more - see examples section below.
- __Note__ — On a server, cookies will be set __only__ after headers are sent (on next route or page reload). To send cookies from *Client* to *Server* without a page reload use `send()` method.
- __Server Usage Note__ — On a server Cookies implemented as a middleware. To get access to current user's cookies use `req.Cookies` instance. For more - see examples section below.

### Fetch cookies `new Cookies(opts)` [*Isomorphic*]

Expand Down
6 changes: 3 additions & 3 deletions cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ if (Meteor.isServer) {

const NoOp = () => {};
const urlRE = /\/___cookie___\/set/;
const rootUrlRE = Meteor.isServer ? process.env.ROOT_URL : (window.__meteor_runtime_config__.ROOT_URL || window.__meteor_runtime_config__.meteorEnv.ROOT_URL || false);
const mobileRootUrlRE = Meteor.isServer ? process.env.MOBILE_ROOT_URL : (window.__meteor_runtime_config__.MOBILE_ROOT_URL || window.__meteor_runtime_config__.meteorEnv.MOBILE_ROOT_URL || false);
const originRE = new RegExp(`^https?:\/\/(localhost:12\\d\\d\\d${rootUrlRE ? ('|' + rootUrlRE) : ''}${mobileRootUrlRE ? ('|' + mobileRootUrlRE) : ''})$`);
const rootUrl = Meteor.isServer ? process.env.ROOT_URL : (window.__meteor_runtime_config__.ROOT_URL || window.__meteor_runtime_config__.meteorEnv.ROOT_URL || false);
const mobileRootUrl = Meteor.isServer ? process.env.MOBILE_ROOT_URL : (window.__meteor_runtime_config__.MOBILE_ROOT_URL || window.__meteor_runtime_config__.meteorEnv.MOBILE_ROOT_URL || false);
const originRE = new RegExp(`^https?:\/\/(localhost:12\\d\\d\\d${rootUrl ? ('|' + rootUrl) : ''}${mobileRootUrl ? ('|' + mobileRootUrl) : ''})$`);

const helpers = {
isUndefined(obj) {
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: 'ostrio:cookies',
version: '2.4.0',
version: '2.4.1',
summary: 'Isomorphic bulletproof Server, Client, Browser and Cordova cookies',
git: 'https://github.com/VeliovGroup/Meteor-Cookies',
documentation: 'README.md'
Expand Down

0 comments on commit 722c07b

Please sign in to comment.