Search code examples
ember.jsember-cli

how to deploy ember-cli project in apache server


I have the following problem.

I created an ember application with ember-cli.

The application works fine on nodejs through the url http://localhost:4200/ when running the command ember serve

I want to deploy this application on an apache httpd server.

In order that this will work i think that it should work also standalone when opening in firefox.

When i open it in firefox i get an error:

require is not defined

The generated index.html is

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Foo</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1 user-scalable=no">

    <base href="/" />

    <link rel="stylesheet" href="assets/vendor.css">
    <link rel="stylesheet" href="assets/foo.css">
  </head>
  <body>
    <script>
      window.FooENV = {"environment":"development","baseURL":"/","locationType":"auto","EmberENV":{"FEATURES":{}},"APP":{"LOG_RESOLVER":true,"LOG_ACTIVE_GENERATION":true,"LOG_MODULE_RESOLVER":true,"LOG_VIEW_LOOKUPS":true},"LOG_MODULE_RESOLVER":true};
      window.EmberENV = window.FooENV.EmberENV;
    </script>
    <script src="assets/vendor.js"></script>
    <script src="assets/foo.js"></script>
    <script>
      window.Foo = require('foo/app')['default'].create(FooENV.APP);
    </script>
  </body>
</html>

How can i solve this issue?

Thanks,

David


Solution

  • file:///J:/assets/ndd.css
    

    This looks to me like you just double clicked your index.html file in your dist folder. This does not work!

    You have to serve your directory by an http-server.

    Install a simple http server with npm:

    npm install -g http-server
    

    Move to your dist folder and run http-server. You will see a message like this:

    Starting up http-server, serving ./ on port: 8080
    

    Now you can check your ember app in Firefox on: http://localhost:8080