Comments (2)
Thanks for opening an issue.
This is a good question and one that I'll soon need to solve too 😉.
In another project of mine, with the help of inert
, I define a directory handler for the path /public/{param*}
. So essentially I put all my front-end assets (images/css/js) under one path.
I need to experiment with some different configurations, but I'd imagine that the specificity of the directory route handler would suffice.
from hapi-react-views.
As a follow up to this, in another project I have my static assets served with the help of inert
like this:
server.route({
method: 'GET',
path: '/public/{param*}',
handler: {
directory: {
path: 'public',
listing: true
}
}
});
Then I have a catch-all style handler that globs everything like this:
server.route({
method: 'GET',
path: '/{glob*}',
handler: internals.routeHandler
});
Because I use a shared route handler I defined (internals.routeHandler
), I'm even able to intercept requests to specific routes for special case handling (like redirecting or querying data) and then pass them back to internals.routeHandler
. Similar to:
server.route({
method: 'GET',
path: '/login/{glob*}',
config: {
auth: {
mode: 'try',
strategy: 'session'
},
plugins: {
'hapi-auth-cookie': {
redirectTo: false
}
}
},
handler: function (request, reply) {
if (request.params.glob !== 'logout' &&
request.auth.isAuthenticated) {
if (request.auth.credentials.user.roles.admin) {
return reply.redirect('/admin');
}
return reply.redirect('/account');
}
if (!request.auth.isAuthenticated) {
request.app.headers = {
'x-auth-required': true
};
}
internals.routeHandler(request, reply)
}
});
And I'm not having any MIME type issues. I hope this helps.
from hapi-react-views.
Related Issues (20)
- Update dependencies HOT 5
- Update readme examples for new version of hapijs/glue HOT 1
- React: onClick does not work HOT 3
- Layout feature proposal HOT 12
- Layout feature requires JSX file extension HOT 3
- Babel transpile JSX to JS - Handling for different file extensions HOT 7
- Support removeCache option for any file extension HOT 1
- Improving performance through streaming HOT 6
- Babel-register on production HOT 1
- How do I set the `title` when using a layout? HOT 2
- how to pass props to layout? HOT 1
- Update to react v16 HOT 1
- Git Clone Link not working HOT 1
- Not issue but recommendation for updating documentation HOT 1
- additional rendering options HOT 2
- Update dependencies HOT 1
- can't use jsx file when build ahead of time HOT 3
- Update hoek dep HOT 2
- React.createFactory() is deprecated and will be removed in a future major release.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hapi-react-views.