Skip to content

Commit

Permalink
Merge pull request #281 from jihchi/dependabot/npm_and_yarn/koa/cors-…
Browse files Browse the repository at this point in the history
…5.0.0

Bump @koa/cors from 4.0.0 to 5.0.0
  • Loading branch information
jihchi authored Mar 14, 2024
2 parents 3793fa0 + 4702949 commit 2d1998a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"dependencies": {
"@fortawesome/fontawesome-free": "^6.4.2",
"@koa/cors": "^4.0.0",
"@koa/cors": "^5.0.0",
"debug": "^4.3.4",
"js-base64": "^3.7.5",
"koa": "^2.14.2",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ const debug = createDebug('app:main');
const pptr = createDebug('app:pptr');
const app = new Koa();

app.use(cors({ allowMethods: 'GET' }));
app.use(
cors({
allowMethods: 'GET',
origin(ctx) {
return ctx.get('Origin') || '*';
},
})
);
app.use(route.get('/', views.home));
app.use(route.get('/services/oembed', views.servicesOembed));
app.use(route.get('/img/:encodedCode', views.img));
Expand Down
3 changes: 2 additions & 1 deletion test/kitchensink.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ describe('app', () => {
});

describe('Fixed #272, ER diagram', () => {
const encodedPath = 'pako:eNpFjrEKwzAMRH_F3FjyBd4CXTt1a9VBxEpqiO3gyEMJ_ve4SaE36R6H7jYMyQksJF89T5kDRdPUPwn9hfAy2wm-WjX7OJn-JJUiOgTJgb1rH44gQd8ShGDb6WTkMiuBYm1RLprunzjAai7SoSyOVX61sCPPa6MLx0dKfy_Oa8q3c-Uxtu7OaTo4';
const encodedPath =
'pako:eNpFjrEKwzAMRH_F3FjyBd4CXTt1a9VBxEpqiO3gyEMJ_ve4SaE36R6H7jYMyQksJF89T5kDRdPUPwn9hfAy2wm-WjX7OJn-JJUiOgTJgb1rH44gQd8ShGDb6WTkMiuBYm1RLprunzjAai7SoSyOVX61sCPPa6MLx0dKfy_Oa8q3c-Uxtu7OaTo4';

test('img', async () => {
const resp = await request.get(`/img/${encodedPath}`);
Expand Down

0 comments on commit 2d1998a

Please sign in to comment.