netlify-cms-cloudflare-pages
netlify-cms-cloudflare-pages copied to clipboard
Wrong message structure may cause token unset
Description
This is the message pattern the repo is using
https://github.com/i40west/netlify-cms-cloudflare-pages/blob/7b427946965f0c5fd33ddd04db0b62bb73a4f0a3/functions/api/callback.js#L6
which will return messages like authorization:github:success:"data: gho_xxxxxxx"
and decap is now using JSON.parse to parse this field of information, see
https://github.com/decaporg/decap-cms/blob/5940784fc6e8ef1a498c6c942c5caa15d6c47b92/packages/decap-cms-lib-auth/src/netlify-auth.js#L60
JSON.parse("data: gho_xxxxxxx") returns a string type variable which will cause decap cannot get the access_token.
My Solution to this
// ...
'authorization:github:${status}:${content}',
// ...
const responseBody = renderBody('success', `{"token":"${token}"}`)
// ...