Skip to content

Instantly share code, notes, and snippets.

View jonathansanchez's full-sized avatar
🏠
Working from home

Jonathan Sánchez jonathansanchez

🏠
Working from home
View GitHub Profile
@ricsiga
ricsiga / varnish_redirect_example.vcl
Last active November 30, 2019 17:46
redirect in Varnish 4
sub vcl_recv {
if (req.http.host == "www.example.com") {
set req.http.location = "http://example.com" + req.url;
return (synth(750, "Permanently moved"));
}
}
sub vcl_synth {
if (resp.status == 750) {
set resp.http.location = req.http.location;
@jesperorb
jesperorb / cors.md
Last active February 21, 2024 14:17
Handle CORS Client-side

Handle CORS Client-side

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the first resource was served. This is set on the server-side and there is nothing you can do from the client-side to change that setting, that is up to the server/API. There are some ways to get around it tho.

Sources : MDN - HTTP Access Control | Wiki - CORS

CORS is set server-side by supplying each request with additional headers which allow requests to be requested outside of the own domain, for example to your localhost. This is primarily set by the header:

Access-Control-Allow-Origin
@technoknol
technoknol / log4php-for-laravel.php
Created May 4, 2017 13:04
Working log4php in Laravel (5.4)
<?php
// Middleware:
// app\Http\Middleware\log4php.php
namespace App\Http\Middleware;
use Closure;
class log4php
{