casdoor / casdoor-vue-sdk

Vue client SDK for Casdoor
https://github.com/casdoor/casdoor
Apache License 2.0
15 stars 10 forks source link

Nuxt 3-> Failed to load resource: the server responded with a status of 504 (Gateway Timeout) #17

Closed Kingside88 closed 2 years ago

Kingside88 commented 2 years ago

Hi, I am not sure if I am doing something wrong or there is a bug. I want to use it with nuxt 3. I created a filte "casdoor.ts" under plugins folder with following lines of code (modified):

`import Casdoor from 'casdoor-vue-sdk'

const config = { serverUrl: "https://casdoor.devandy.de", clientId: "xxx", organizationName: "xxx", appName: "xxx", redirectPath: "/callback", requireHttpsMetadata: false };

export default defineNuxtPlugin(async nuxtApp => { nuxtApp.vueApp.use(Casdoor, config) }) And under **composables**: import { useCasdoor } from 'casdoor-vue-sdk';

export default { setup() {

const { getSigninUrl, getSignupUrl } = useCasdoor();

function login() {
  window.location.href = getSigninUrl();
}

function signup() {
  window.location.href = getSignupUrl();
}

return {
  login,
  signup
}

} }`

But than I got an JavaScript Error: Failed to load resource: the server responded with a status of 504 (Gateway Timeout) RequestURL: http://localhost:3000/_nuxt/node_modules/.vite/deps/ufo.js?v=dcaeb125

casbin-bot commented 2 years ago

@seriouszyx @ComradeProgrammer @Resulte

DevRickLin commented 2 years ago

Hi, I am not sure if I am doing something wrong or there is a bug. I want to use it with nuxt 3. I created a filte "casdoor.ts" under plugins folder with following lines of code (modified):

`import Casdoor from 'casdoor-vue-sdk'

const config = { serverUrl: "https://casdoor.devandy.de", clientId: "xxx", organizationName: "xxx", appName: "xxx", redirectPath: "/callback", requireHttpsMetadata: false };

export default defineNuxtPlugin(async nuxtApp => { nuxtApp.vueApp.use(Casdoor, config) }) And under **composables**:import { useCasdoor } from 'casdoor-vue-sdk';

export default { setup() {

const { getSigninUrl, getSignupUrl } = useCasdoor();

function login() {
  window.location.href = getSigninUrl();
}

function signup() {
  window.location.href = getSignupUrl();
}

return {
  login,
  signup
}

} }`

But than I got an JavaScript Error: Failed to load resource: the server responded with a status of 504 (Gateway Timeout) RequestURL: http://localhost:3000/_nuxt/node_modules/.vite/deps/ufo.js?v=dcaeb125

Hello! can you give us more detailed information to reproduce this problem?

We need to know:

  1. Your environment: Operating System: Node Version: Nuxt Version: Nitro Version: Casdoor Version: Package Manager:
  2. The configurations of your nuxt project.
  3. The configurations of your Casdoor deployment.

If possible, you can provide us a minimal reproducible example, such as a docker image that include the project you encountered this problem and it's dependencies, including your frontend and backend would be better.

Thanks for your time.

Kingside88 commented 2 years ago

I figured it out. My problem was, I did not added "Redirect URLs" in casdoor Application. So I added my localhost:3000 entry and then it works fine.