Skip to content

Commit a06d0aa

Browse files
authored
Add CORS for metadata and static file request (#390)
1 parent ad1fcfb commit a06d0aa

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

server/server.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def call(env)
7373

7474
elsif path=='metadata'
7575
# Serve mbtiles metadata
76-
['200', {'Content-Type' => 'application/json', 'Cache-Control' => "max-age=#{@@max_age}" }, [read_metadata.to_json]]
76+
['200', {'Content-Type' => 'application/json', 'Cache-Control' => "max-age=#{@@max_age}", 'Access-Control-Allow-Origin' => '*' }, [read_metadata.to_json]]
7777

7878
# elsif ARGV.include?(path.sub(/\.json$/,'.glug'))
7979
# # Convert .glug style to .json
@@ -84,7 +84,7 @@ def call(env)
8484
elsif File.exist?(path)
8585
# Serve static file
8686
ct = path.match(/\.(\w+)$/) ? (CONTENT_TYPES[$1.to_sym] || 'text/html') : 'text/html'
87-
['200', {'Content-Type' => ct, 'Cache-Control' => "max-age=#{@@max_age}"}, [File.read(path)]]
87+
['200', {'Content-Type' => ct, 'Cache-Control' => "max-age=#{@@max_age}", 'Access-Control-Allow-Origin' => '*'}, [File.read(path)]]
8888

8989
elsif path=~/font.+\.pbf/
9090
# Font not found so send dummy file

0 commit comments

Comments
 (0)