kadirahq / flow-router

Carefully Designed Client Side Router for Meteor
MIT License
1.09k stars 195 forks source link

Public files don’t get served until dev server restarts for the first time #726

Open cpury opened 6 years ago

cpury commented 6 years ago

(Crosspost from https://forums.meteor.com/t/flow-router-public-files-dont-get-served-until-dev-server-restarts-for-the-first-time/39763)

I have a simple app that uses Flow-Router. In my public directory, there are some files that I'd like to be served. This seems to work always when running meteor without flow router. However, when I start the dev server with my route definitions, the static files are not served at all and result in a 404 no matter how many times I clear the cache and refresh. I have to edit some file to trigger a server restart before it works as expected.

Is there something I can do to debug what's going on? Serving public files is supposed to work out of the box with flow router, right?

Here's my routes.js:

import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';

import '../../ui/layouts/app-body.js';
import '../../ui/pages/index-page.html';
...
import '../../ui/layouts/not-found-body.html'

FlowRouter.route('/', {
  name: 'home',
  action() {
    BlazeLayout.render('appBody', { main: 'indexPage' });
  },
});

// ...
// Two more basic routes that have nothing to with /public or similar
// ...

FlowRouter.notFound = {
  action() {
    BlazeLayout.render('notFoundBody');
  },
};

Other info: The routes are defined similarly to the newest TODO example in /imports/startup/client/routes.js and get imported early on the client-side.

I've used Meteor 1.5 but just upgraded to 1.6-rc.5 and the issue still persists.

mywebstudio commented 5 years ago

I have the similar issue. But my app crash when i`m trying ti pass any FlowRouter params, like 'id'

FlowRouter.route('/editproduct/:id', { name: 'editProduct', action: function(params) { BlazeLayout.render('pageContent', {wrapper: 'editProduct' }); } });

without FlowRouter param '/:id' my public files loads correctly in template Problem always comes up on the initial server start Meteor -1.8; FlowRouter - 2.1

mywebstudio commented 5 years ago

Solved. In my case the error was in relative url of static files (css/bootstrap.min.css) loaded as (/editproduct/css/bootstrap.min.css) - that was wrong. Static files should be imported by absolute url like this:
<link href="/css/bootstrap.min.css" rel="stylesheet">