Skip to content

Instantly share code, notes, and snippets.

View frandiox's full-sized avatar
🤷‍♂️
[object Object]

Fran Dios frandiox

🤷‍♂️
[object Object]
View GitHub Profile
@frandiox
frandiox / client-request-ip.md
Created October 23, 2023 10:20
How to get the client IP from the request object in multiple JS runtimes / platforms

When the handler is behind a proxy server

Reference

const ips = request.headers.get('x-forwarded-for'); // comma-separated list of IPs

Node

@frandiox
frandiox / vite.config.js
Created March 30, 2022 01:22
Adding Hydrogen plugin to Vite config
import {defineConfig} from 'vite';
import hydrogen from '@shopify/hydrogen/plugin';
import shopifyConfig from './shopify.config';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [hydrogen(shopifyConfig)],
});
@frandiox
frandiox / worker.js
Created December 16, 2021 06:04
Global request IDs using error stacks
// ---- User code:
addEventListener("fetch", event => {
event.respondWith(handleEvent(event))
})
// ---- Lib code:
const globalStuff = new Map();
async function handleEvent({request}) {
// Generate a unique ID for this request
@frandiox
frandiox / VueOnsTabbar.vue
Last active October 2, 2017 09:54
Swiping tab bar with Onsen UI for Vue
<template>
<v-ons-page>
<v-ons-toolbar :style="swipeTheme">
<div class="center">Swiping Tab Bar</div>
</v-ons-toolbar>
<v-ons-tabbar
swipeable
position="top"
:tabs="tabs"