Comments (13)
context
is only available on server-side.
from deprecated.
I am logging context on the server side but Context argument is undefined in createRouter function for the path "/" and other routes on server-side. Is it possible to use req object in router.beforeEach callback on the server. I am tryinfg to implement global navigation guard on the server.
from deprecated.
I guess we need to implement a server-side redirect
method in context
, using the native next
function in beforeEach((to, from, next) => {})
would not work.
from deprecated.
Hmm, didn't understand you correctly, do you mean something like this?
router.beforeEach((to, from, next) => {
if (to.path === '/private') {
if (process.server && !context.req.session) {
return next('/')
}
if (process.browser && !localStorage.getItem('api-key')) {
return next('/')
}
}
next()
})
from deprecated.
Yes I am trying to do just that with some modifications but I am unable to use custom express server with ream and backpack module. Nuxt works fine with custom express server and backpack https://github.com/nuxt/express. Is ream compatible with backpack? Ream is much better than Nuxt If can solve few issues.
from deprecated.
So is this issue solved already? I can see context
:
Is ream compatible with backpack?
What issues do you run into while using Ream with Backpack? It's just a cli tool to run your node app, so I think it will work fine with Ream. Keep in mind that while using custom express server it's just a normal node app. A repo for reproducing the issue will help a lot.
from deprecated.
Yes after updating to rc.5 context is available in createRouter function. I am trying to build a full stack template with jwt token based authentication/ authorization and a graphql inspired simple data layer with request batching. VueJs is realy great and there should be a full-stack framework based on it.
I am using code from template-ream with my own server code
const dev = process.env.NODE_ENV !== 'production'
const client = ream({dev: dev, entry: 'src/client/index.js'})
client.prepare()
.then(() => {
app.get('*', client.getRequestHandler())
this.instance = app.listen(process.env.PORT || 5000,
(err) => {
if(err) {
Log.error(`Unable to start API server ${process.pid}.`);
Event.emit('shutdown')
} else {
Log.info(`API server ${process.pid} started...`);
}
});
})
client.on('ready', () => {
ream.displayStats(client.stats)
})
Pacjage.json
"start": "backpack build && node ./build/main.js"
Build is successful and server is started. Here is the output
Build also not working with Neutrino, Neutrino Node.js Preset modules
✖ Building project failed
4:01 PM
Jump to
./src/index.js
4:01 PM
Module build failed: Error: Target version must be a number,
4:01 PM
Jump to
'6.9' was given for 'node' (While processing preset: "/app/node_modules/babel-preset-env/lib/index.js")
4:01 PM
Jump to
at /app/node_modules/babel-preset-env/lib/index.js:64:13
4:01 PM
at Array.filter (native)
4:01 PM
Jump to
from deprecated.
It seems that babel-preset-env module is defining node version number as a string and not as a number. Both backback and Neutrino reporting same error. @egoist Could you please suggest a solution.
from deprecated.
that's weird, we didn't define the node version in babel-preset-env
from deprecated.
@egoist My project is hosted on glitch.com. If you can share your email then I can send you an invite on glitch.com
from deprecated.
yup, you can find my email on my profile page
from deprecated.
@egoist I just sent you an invitation of my project on glitch.com
from deprecated.
It's working now thanks for the help.
from deprecated.
Related Issues (20)
- Default error message (You must create pages/*.vue) is misleading
- How to use i18n in my project HOT 5
- Critical: Ream creates invalid Webpack config object HOT 4
- getInitialData is lost when using Vue.extend HOT 4
- Client-side getInitialData redirect to absolute URL shows new component for a moment HOT 1
- Unexpected token initialDataKey HOT 3
- Client-side getInitialData redirect to relative URL doesn't work HOT 1
- with-apollo example is outdated HOT 1
- `ream dev` triple rebuild HOT 3
- Change enhanceApp context API HOT 4
- Vuex example not listing vuex in package.json HOT 5
- how to use postcss
- Disable SSR for some part of code HOT 1
- Ream fails to compile with newest Webpack due to missing uglifyjs HOT 2
- Exception in getInitialDate returns HTTP 200 HOT 1
- Prefetching data with `ssrPrefetch`
- is there any guide for deploy and build? HOT 3
- how to enable babel-polyfill in webpack?
- how to use mqtt in ream for browser?
- In latest webpack, cache is mistakenly reused between server and client builds HOT 3
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 deprecated.