Skip to content

Instantly share code, notes, and snippets.

@milksense
Last active August 3, 2023 03:25
Show Gist options
  • Save milksense/afb9a5022a66cfccfc33f1653faf6629 to your computer and use it in GitHub Desktop.
Save milksense/afb9a5022a66cfccfc33f1653faf6629 to your computer and use it in GitHub Desktop.
Simple Cloudflare Ray ID generator
import randomstring from 'randomstring';
/**
* A Cloudflare Ray ID is a unique identifier given to every request that goes through Cloudflare.
*
* @see https://developers.cloudflare.com/fundamentals/get-started/reference/cloudflare-ray-id/
*
* @returns {string} "Cloudflare" Ray ID.
*/
export default (): string => {
const prefix: string = randomstring.generate({ length: 16, charset: 'hex' });
const difficulty: number = 13; // or smth else
return `Ray ID: ${prefix}-${difficulty}`;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment