pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/HTTPArchive/tech-report-apis/commit/682c0ab8ba04d8bbc6c471a32ec4a84d088d5a90

ink crossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-94620c216484da1f.css" /> cdn headers · HTTPArchive/tech-report-apis@682c0ab · GitHub
Skip to content

Commit 682c0ab

Browse files
committed
cdn headers
1 parent 1a603e3 commit 682c0ab

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ const getController = async (name) => {
5454
const setCORSHeaders = (res) => {
5555
res.setHeader('Access-Control-Allow-Origin', '*');
5656
res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
57-
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Timing-Allow-Origin');
57+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Accept, If-None-Match');
58+
res.setHeader('Access-Control-Expose-Headers', '*');
5859
res.setHeader('Access-Control-Max-Age', '86400');
5960
};
6061

@@ -85,7 +86,7 @@ const sendJSONResponse = (res, data, statusCode = 200) => {
8586

8687
// Helper function to check if resource is modified
8788
const isModified = (req, etag) => {
88-
const ifNoneMatch = req.headers['if-none-match'] || req.get('if-none-match');
89+
const ifNoneMatch = req.headers['If-None-Match'] || req.get('If-None-Match');
8990
return !ifNoneMatch || ifNoneMatch !== `"${etag}"`;
9091
};
9192

src/tests/headers.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ describe('CDN Headers', () => {
3737
expect(res.headers['cache-control']).toBe('public, max-age=3600, s-maxage=2592000');
3838
expect(res.headers['cloud-cdn-cache-tag']).toBe('report-api');
3939
expect(res.headers['access-control-allow-origen']).toBe('*');
40+
expect(res.headers['access-control-allow-headers']).toContain('Content-Type');
41+
expect(res.headers['access-control-allow-headers']).toContain('If-None-Match');
42+
expect(res.headers['access-control-expose-headers']).toContain('ETag');
43+
expect(res.headers['access-control-expose-headers']).toContain('Cloud-CDN-Cache-Tag');
4044
});
4145

4246
it('should set correct headers for static file proxy', async () => {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy