Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

JavaScript How to configure oauth in sveltia cms and integrate with sveltekit, deploy to vercel?

Coding Nguyen

New Coder

hello​

I am building a website written with sveltekit, tailwindCss, sveltia cms and deploying to vercel. However, I am having difficulty logging into sveltia cms. Specifically, I cannot configure oauth and when accessing the url/admin it cannot login through my github. The website is located in the /site/htdocs/ directory and the bug is in the admin section. I really hope you can help me solve this problem. Thanks, I hope to receive help from the community. If you are interested you can check out my repo
here link
 
Last edited:

hello​

I am building a website written with sveltekit, tailwindCss, sveltia cms and deploying to vercel. However, I am having difficulty logging into sveltia cms. Specifically, I cannot configure oauth and when accessing the url/admin it cannot login through my github. The website is located in the /site/htdocs/ directory and the bug is in the admin section. I really hope you can help me solve this problem. Thanks, I hope to receive help from the community. If you are interested you can check out my repo
here link

Hello,


I have not personally used sveltekit but from what I have read you can try troubleshooting some of the following:

1. Verify GitHub OAuth Settings:
  • Ensure you've created a GitHub OAuth app at GitHub Developer Settings.
  • Set the "Authorization callback URL" to point to your deployed site's admin OAuth redirect URL (e.g., https://your-domain.com/admin/auth/callback).
2. Update Sveltia CMS Configuration:
  • In your sveltia.config.js or similar configuration file, ensure you have the correct client ID and secret from GitHub.
Example:
JavaScript:
export default {
  auth: {
    providers: {
      github: {
        clientId: 'your-client-id',
        clientSecret: 'your-client-secret',
      },
    },
  },
};

3. Environment Variables:
  • Store your GitHub client ID and secret securely in Vercel's environment variables (GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET).
  • Update your app to read these values:
JavaScript:
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,

4. Redirect Issues:
  • Ensure your /admin route correctly proxies or handles the OAuth flow.
  • Check the redirect_uri passed during the OAuth request matches what is set in GitHub.

Hope this will help resolve the issues. Let me know if you continue expierencing any problems.
 
Hey There !
In order to troubleshoot SvelteKit GitHub OAuth issues, verify your GitHub OAuth settings by ensuring the callback URL (e.g., https://your-domain.com/admin/auth/callback) is correctly set in your GitHub app. Update your Sveltia CMS configuration to include the GitHub client ID and secret, storing them securely in environment variables (e.g., GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET) and referencing them via process.env. Ensure your /admin route correctly handles the OAuth flow and that the redirect_uri matches the GitHub configuration.
JavaScript:
export default {
  auth: {
    providers: {
      github: {
        clientId: 'your-client-id',
        clientSecret: 'your-client-secret',
      },
    },
  },
};
 
Hey There !
In order to troubleshoot SvelteKit GitHub OAuth issues, verify your GitHub OAuth settings by ensuring the callback URL (e.g., https://your-domain.com/admin/auth/callback) is correctly set in your GitHub app. Update your Sveltia CMS configuration to include the GitHub client ID and secret, storing them securely in environment variables (e.g., GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET) and referencing them via process.env. Ensure your /admin route correctly handles the OAuth flow and that the redirect_uri matches the GitHub configuration.
JavaScript:
export default {
  auth: {
    providers: {
      github: {
        clientId: 'your-client-id',
        clientSecret: 'your-client-secret',
      },
    },
  },
};
I tried doing it your way and when accessing localhost:5173/oauth it worked. However, the sad thing here is that the cms is corrupted, meaning that when accessing localhost:5173/admin, it no longer displays the cms. also, i wonder how to change its path url for example i want it to be localhost:5173/oauth/callback instead of localhost:5173/callback because i want it to work properly with the configuration on github and environment variables on vercel. Thanks for your help and please review my code in the repo.
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom