GithubHelp home page GithubHelp logo

Comments (8)

pavelfeldman avatar pavelfeldman commented on August 19, 2024 1

The idea behind serveOrigin is that it is used for dev mode and overrides serveFolder. Carlo should not be used without serveFolder, because it defeats Carlo's purpose. You can run express and point your browser to the port if all you want is serve.

from carlo.

vsemozhetbyt avatar vsemozhetbyt commented on August 19, 2024

Did you update carlo to the last master state?

from carlo.

kraciasty avatar kraciasty commented on August 19, 2024

Yes, it's the latest.

from carlo.

vsemozhetbyt avatar vsemozhetbyt commented on August 19, 2024

H'm. I have a different issue:

'use strict';

const carlo = require('carlo');

(async function main() {
  try {
    const app = await carlo.launch();
    app.on('exit', () => process.exit());

    app.serveOrigin('https://example.org');

    console.log(app.serveOrigin);

    await app.load('index.html');

    console.log(await app.evaluate(() => location.href));
  } catch (err) {
    console.error(err);
  }
})();
[Function: serveOrigin]
Error: Please call app.serveFolder(__dirname) or point to other folder(s) with your web files
    at App.load (carlo\lib\carlo.js:122:13)
    at main (test.js:14:15)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)

from carlo.

kraciasty avatar kraciasty commented on August 19, 2024

My bad,
UnhandledPromiseRejectionWarning with npm 0.9.11
master results are same as yours

from carlo.

kraciasty avatar kraciasty commented on August 19, 2024

I got it to launch by adding app.serveFolder('@')

'use strict';

const carlo = require('carlo');

(async function main() {
  try {
    const app = await carlo.launch();
    app.on('exit', () => process.exit());

    app.serveOrigin('https://example.org');
    app.serveFolder('@')

    console.log(app.serveOrigin);

    await app.load('index.html');

    console.log(await app.evaluate(() => location.href));
  } catch (err) {
    console.error(err);
  }
})();

from carlo.

vsemozhetbyt avatar vsemozhetbyt commented on August 19, 2024

I can also manage with this:

'use strict';

const carlo = require('carlo');

(async function main() {
  try {
    const app = await carlo.launch();
    app.on('exit', () => process.exit());

    app.serveOrigin('https://example.org');
    app.serveFolder('/');
    await app.load('index.html');

    console.log(await app.evaluate(() => location.href));
  } catch (err) {
    console.error(err);
  }
})();

(The location is a bit confusing though: https://domain/index.html)

Maybe doc example needs to be updated with app.serveFolder() added?

from carlo.

kraciasty avatar kraciasty commented on August 19, 2024

Perhaps it could be changed in load() ?

load(uri = '') {
  if (!this.www_.size) {
    if (this.wwwOrigin_) {
      this.www_.set('/');
    } else {
      this.page_.close();
      throw new Error('Please call app.serveFolder(__dirname) or point to ' +
                      'other folder(s) with your web files');
    }
  }
  return this.page_.goto(`https://domain/${uri}`, {timeout: 0});
}

And it'd be implicitly set, saving from confusion as mentioned above

app.serveOrigin('https://example.org');
// app.serveFolder('/');
await app.load(); // no URI passed

from carlo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.