Comments (9)
I guess you mean custom server? If you're using express you can use express-jwt, no example for now.
from deprecated.
I am using express-jwt and express session to store token in a cookie. How can I set axios header, authorize routes and access token in vue components. Nuxt uses middle ware to set axios header like this
import axios from 'axios'
export default function({isServer, req}) {
if (isServer) {
axios.defaults.headers.common.cookie = req.headers.cookie
}
}
and then store token in store
nuxtServerInit ({ commit }, { req }) {
if (req.session && req.session.authUser) {
commit('SET_USER', req.session.authUser)
}
}
from deprecated.
@egoist An authentication/route authorization example with express-jwt and custom expressjs server would be very useful for developers new to Ream.
from deprecated.
@ansarizafar
you can do this like in all other vuejs apps with or without ream
you cann follow this: https://github.com/auth0-blog/vue-jwt-authentication this will give you the idea but dont forget to use bcrypt to save the password on serverside they dont show this part
from deprecated.
I've already explained that to him, but he keeps asking: ream/ream#23 (comment)
I'm guessing he hasn't gone through any tutorials yet.
from deprecated.
I am using Token based authentication in my projects from last 3 years. @cannap the tutorial you mentioned is about client side. If routes/pages are rendered on the server then you can't get token from localstorage as there is no localstorage available on the server. See how it can be done with Nuxt https://nuxtjs.org/examples/auth-routes
from deprecated.
Since you've been doing it for 3 years, how do you normally get the token to the server? Just add it to a header, or to the body, or in the query string when you make the request.
from deprecated.
@egoist Could you please suggest a solution, especially for those who don't understand how SSR works.
from deprecated.
I added a simple auth example: https://github.com/ream/ream/tree/master/examples/with-auth
This does not include an API implementation but only a client workflow.
Basically you only need to check if it's a valid user in entry file's middleware
method or component's getInitialData
method:
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.