floatinghotpot / cordova-httpd

Embed tiny web server into Cordova with a plugin
285 stars 148 forks source link

Break SVG loading #54

Open Speuta opened 7 years ago

Speuta commented 7 years ago

I use img tags with svg link inside <img src="relative/path/to/myImage.svg"/> and the link is good (http://localhost:8080/path/to/myimage.svg), but they are not displayed..

Looking in the Network tab, the image respond with 200 Status code, and I don't know where this problem can come from...

I've tried a lot of CSP configs, but no one seems to work..

Speuta commented 7 years ago

Found the solution, Can you add svg MIME type to NanoHTTPD.java file ? I added "svg image/svg+xml "+ on line 1114, and it work fine. Thank you !!

Speuta commented 7 years ago

Any idea how to fix the same problem in Cocoa for iOs ?

thanhnhan2tn commented 7 years ago

I have the same issue on IOS too. Do you have any solutions?

thanhnhan2tn commented 7 years ago

Hi @devAxeon try this https://github.com/robbiehanson/CocoaHTTPServer/issues/106

kelby-rogers-ctct commented 6 years ago

@devAxeon To add SVG support on iOS add the following to HTTPFileResponse.m

- (NSDictionary *)httpHeaders {
  //HTTPLogTrace();
  if ([[filePath pathExtension] isEqualToString:@"svg"]) {
    return [NSDictionary dictionaryWithObject:@"image/svg+xml" forKey:@"Content-Type"];
  }
  return [NSDictionary new];
}