Skip to content

Instantly share code, notes, and snippets.

Trần Văn Luận luandevpro

  • Viet Nam
Block or report user

Report or block luandevpro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View workers.js
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
async function fetchAndApply(request) {
let uaSuffix = ''
const ua = request.headers.get('user-agent')
if (ua.match(/iphone/i) || ua.match(/ipod/i)) {
uaSuffix = '/mobile'
View workers.js
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
async function fetchAndApply(request) {
if (request.headers.get('cf-connecting-ip') !== '225.0.0.1') {
return new Response('Sorry, this page is not available.',
{ status: 403, statusText: 'Forbidden' })
}
View workers.js
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
async function fetchAndApply(request) {
const country = request.headers.get('Cf-Ipcountry').toLowerCase()
let url = new URL(request.url)
const target_url = 'https://' + url.hostname + '/' + country
View workers.js
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
async function fetchAndApply(request) {
const init = {
method: 'GET',
headers: {'Authorization': 'XXXXXX'}
}
const [btcResp, ethResp, ltcResp] = await Promise.all([
View workers.js
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
return fetch("https://test-coder9s.sgp1.digitaloceanspaces.com/index.html")
}
View workers.js
addEventListener('fetch', event => {
event.respondWith(new Response('<html><body><p>Hello world!</p></body></html>'))
})
View workers.js
addEventListener('fetch', event => {
event.respondWith(block(event.request));
});
// Add countries to this Set to block them.
const countries = new Set([
'US', // United States.
'SG', // Singapore.
'BR', // Brazil.
'PK', // Pakistan.
View workers.js
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
return new Response('hello world', {status: 200})
}
View index.js
import PropTypes from 'prop-types';
import { useQuery } from '@apollo/react-hooks';
import withApollo from '../lib/withApollo';
import { userByPk } from '../graphql/users/query';
const Index = ({ user }) => {
const { loading, error, data } = useQuery(userByPk);
if (loading) return <div>Loading...</div>;
if (error) return <div>{error.message}</div>;
return (
View initApollo.js
import fetch from 'isomorphic-fetch';
import { ApolloClient } from 'apollo-client';
import { createHttpLink } from 'apollo-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { split } from 'apollo-link';
import { getMainDefinition } from 'apollo-utilities';
import { setContext } from 'apollo-link-context';
import { WebSocketLink } from 'apollo-link-ws';
let apolloClient = null;
You can’t perform that action at this time.