Skip to content

Commit f5736bd

Browse files
committed
Allow CORS
1 parent a75abf3 commit f5736bd

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

api/[width].js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
const allow = require("allow-cors");
12
const loremPix = require("..");
23

34
module.exports = (request, response) => {
45
const { width } = request.query;
56

7+
allow(response);
8+
69
const data = loremPix(Number(width))
710
.replace(/^data:image\/png;base64,/, "");
811

api/[width]/[height].js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
const allow = require("allow-cors");
12
const loremPix = require("../..");
23

34
module.exports = (request, response) => {
45
const { width, height } = request.query;
56

7+
allow(response);
8+
69
const data = loremPix(Number(width), Number(height))
710
.replace(/^data:image\/png;base64,/, "");
811

api/[width]/[height]/[color].js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
const allow = require("allow-cors");
12
const loremPix = require("../../..");
23

34
module.exports = (request, response) => {
45
const { width, height, color } = request.query;
56

7+
allow(response);
8+
69
const data = loremPix(Number(width), Number(height), color)
710
.replace(/^data:image\/png;base64,/, "");
811

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
},
2020
"license": "MIT",
2121
"dependencies": {
22+
"allow-cors": "^1.0.0",
2223
"canvas": "^2.6.1",
2324
"clamp": "^1.0.1"
2425
},

0 commit comments

Comments
 (0)