简体   繁体   English

Vue.js,Express Server,Okta,通过隐式/回调部署到Heroku,404

[英]Vue.js, Express Server, Okta, deploy to Heroku, 404 on implicit/callback

I have an Vue app built with vue-cli and authorized through Okta. 我有一个用vue-cli构建并通过Okta授权的Vue应用。 Pushed up to Heroku as a production setup, but I'm kinda wondering if Okta doesn't do production on the freemium level? 被推到Heroku作为生产设置,但是我有点想知道Okta是否不会在免费增值产品级别进行生产?

Am I missing something in the docs about this... 我是否在文档中缺少与此相关的内容...

The setup: 设置:

Got a src dir with the usual things router/index.js has Okta library attached: 有一个src目录,其中有router/index.js附带的Okta库的常用内容:

Vue.use(Auth, {
  issuer: 'dev_url',
  client_id: 'some_string',
  redirect_uri: window.location.origin + '/implicit/callback',
  scope: 'openid profile email'
})

and this is in the routes array: 这是在路由数组中:

{
  path: '/implicit/callback',
  component: Auth.handleCallback()
},

Got a server.js in src/ and got some jwt verification and build folder: src/有一个server.js ,并得到了一些jwt验证并建立了文件夹:

app.use(express.static(path.join(__dirname, "../dist")))
...
const oktaJwtVerifier = new OktaJwtVerifier({
    clientId: '<some_id>',
    issuer: '<some_url>'
})
...
app.get('/', authRequired(), (req, res, next) => {
    return res.sendFile(path.join(__dirname, '../dist/index.html'))
 })

These all seem good, and everything works like a charm on localhost. 这些看起来都不错,并且一切都像在localhost上一样起作用。 Working with webpack-dev-server, but with a push up to heroku I get a 404 on the implicit/callback route... 使用webpack-dev-server,但将其推送到heroku,我在implicit/callback路由上得到404 ...

Here are the scripts: 以下是脚本:

"scripts": {
    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
    "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
    "test": "npm run unit",
    "lint": "eslint --ext .js,.vue src test/unit",
    "build": "node build/build.js",
    "server": "node ./src/server",
    "start": "node ./src/server",
    "heroku-prebuild": "npm install && npm run build"
},

When build goes through and all the happy times should commence I click on login and this call gets sent out through the browser, which seems a bit weird: 当构建完成并且所有的快乐时光应该开始时,我单击登录,然后通过浏览器发出此调用,这看起来有点奇怪:

https://<base_url>.herokuapp.com/implicit/callback#id_token=<huge_hashed_string>&token_type=Bearer&expires_in=3600&scope=openid+email+profile&state=<huge_hashed_string>

And we crash out on the 404 and no auth occurs. 而且我们在404上崩溃了,没有身份验证发生。

If you clone it and npm install you can run npm run dev and npm start . 如果克隆它并npm install ,则可以运行npm run devnpm start

Things I've tried: 我尝试过的事情:

It's been a lot of route manipulation, not sure what else to mess around with, mostly because it works locally honestly I think I'm either missing something in setting up the Okta app or something in the docs that won't let me run things this way. 路由操作很多,不确定要搞什么,主要是因为它在本地诚实工作,我认为我要么在设置Okta应用程序时遗漏了一些东西,要么在文档中遗漏了一些不允许我运行的东西这条路。

I've added the production url to Login redirect URIs in dashboard setup. 我已将生产URL添加到仪表板设置中的“ 登录”重定向URI中。 and accepted base urls. 和可接受的基本网址。 Anyone have any input on this one? 有人对此有任何意见吗?

Well it's not too bad. 嗯,还不错。 The answer I found is that you have to go back to token storage and use the OktaClient instead of their implicit callback setup. 我发现的答案是,您必须返回令牌存储并使用OktaClient而不是其隐式回调设置。 Solved the problem by following This tutorial. 通过遵循本教程解决了该问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM