electron: Custom protocol example doesn't work in windows

Hello,

i am trying to “hack” the file protocol in electron so that i can treat absolute paths. On os x everything works fine.

On windows, i can’t get the example from the protocol documentation to work, it throws an ERR_FILE_NOT_FOUND error. I am feeding a path string in the form atom:///path/to/index.html and also tried registering atom as a standard scheme.

The error occurs at startup when calling win.loadURL().

If I call file:///path/to/index.html, the file is loaded correctly (however, subsequent resources with absolute paths fail), but no combination of registerFileProtocol or interceptFileProtocol worked for me, even if i explicitly return the string file:///path/to/index.html in the callback, i get the error message.

Any insights would be appreciated.

Upvotes: 1

Views: 1958

Answers (1)

Many thanks to enlight. Let me share his answer verbatim:

ERR_FILE_NOT_FOUND probably means the path you're passing to the callback is invalid, the callback takes an absolute file system path, not a URL. So calling callback('file:///path/to/index.html') won't work, but callback('C:\\path\\to\\index.html') should work (assuming the file exists).

Upvotes: 1

Related Questions