Socket
Socket
Sign inDemoInstall

electron-protocol-serve

Package Overview
Dependencies
0
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    electron-protocol-serve

A file protocol that serves any existing file in a directory and redirects everything not found to index.html.


Version published
Maintainers
2
Install size
22.3 kB
Created

Changelog

Source

v1.4.0 (2020-04-26)

:rocket: Enhancement
  • #4 If a URL points to a directory, look for an index.html (@bendemboski)
:bug: Bug Fix
  • #10 Omit callback to registerFileProtocol on Electron >= 7 (Closes #9) (@jacobq)
:memo: Documentation
:house: Internal
Committers: 3

Readme

Source

electron-protocol-serve

A file protocol that serves any existing file in a directory and redirects everything not found to index.html.

Made for ember-electron.

Usage

If you want to use it directly, you may do so at your own risk. Remember to register protocols and schemes before app.on('ready').

In your electron.js file:

const { app, protocol, BrowserWindow } = require('electron');
const protocolServe = require('electron-protocol-serve');

// Create the protocol
const filePath = 'path/to/your/dist/folder';
const protocolServeName = protocolServe({cwd: filePath, app, protocol });

// The protocol we created needs to be registered
protocol.registerStandardSchemes([protocolServeName], { secure: true });

// After registering protocol and schema, you can use it to serve your app to your window
app.on('ready', () => {
  mainWindow = new BrowserWindow();

  mainWindow.loadUrl('serve://dist'); // Will serve index.html from the folder you specified
});

API

See index.js.

Credits

FAQs

Last updated on 26 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc