curt curt - 2 years ago 170
Dart Question

Running AngularDart on Apache

My Angular Dart site runs fine with pub serve. I would prefer to run it with Apache. When I enter the url jazzcat.loc/index.html I get the following browser errors:

GET http://jazzcat.loc/packages/browser/dart.js index.html:22
GET http://jazzcat.loc/packages/polymer/polymer.dart package:polymer/polymer.dart:1
An error occurred loading file: package:polymer/polymer.dart index.html:22
GET http://jazzcat.loc/packages/angular2/platform/browser.dart package:angular2/platform/browser.dart:1
An error occurred loading file: package:angular2/platform/browser.dart
index.html:22 GET http://jazzcat.loc/packages/jazzcat/app_component.dart package:jazzcat/app_component.dart:1
An error occurred loading file: package:jazzcat/app_component.dart favicon.ico:1
GET http://jazzcat.loc/favicon.ico 404 (Not Found)

The virtual host entry for the site is:

<VirtualHost *:80>
ServerName jazzcat.loc
DocumentRoot /Volumes/Data/htdocs/jazzcat/web

<directory /Volumes/Data/htdocs/jazzcat/web>
Allow from all
Options -MultiViews
Require all granted

There is no .htaccess file

This is index.html:

<!DOCTYPE html>
<title>Jazz Cat</title>
window.Polymer = window.Polymer || {};
window.Polymer.dom = 'shadow';

<!-- For testing using pub serve directly use: -->
<base href="/">
<!-- For testing in WebStorm use: -->
<!-- base href="/dart/web/" -->

<link href="master.css" rel="stylesheet" type="text/css" />
<script defer src="main.dart" type="application/dart"></script>
<script defer src="packages/browser/dart.js"></script>

I also tried using

<base href="/dart/web/">

It also errors out. I'm testing in the Chromium browser.

I've seen questions and answers here about routing. They seem to apply to routing beyond index.html.

Answer Source

AFAIK pub serve is meant to be used during development, if you want to use apache to serve your app, you might need to use pub build to transform (and optimize) your app to a regular html+javascript app, here you might find more information.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download