Open DR-DinoMight opened 1 year ago
Hi, could you also provide the your Astro config please? If you have the auth config in a seperate file please also send this :)
Sure thing here's the astro config
import { defineConfig } from "astro/config";
import mdx from "@astrojs/mdx";
import tailwind from "@astrojs/tailwind";
import image from "@astrojs/image";
import sitemap from "@astrojs/sitemap";
import prefetch from "@astrojs/prefetch";
import react from "@astrojs/react";
// https://astro.build/config
import netlify from "@astrojs/netlify/functions";
// https://astro.build/config;
import auth from "auth-astro"
// https://astro.build/config
export default defineConfig({
site: "https://deloughry.co.uk",
markdown: {
shikiConfig: {
theme: "poimandres",
wrap: false
}
},
output: "server",
integrations: [mdx({}), tailwind({
config: {
applyBaseStyles: false
}
}), image({
serviceEntryPoint: "@astrojs/image/sharp"
}),
sitemap(),
prefetch(),
react(),
auth(),
],
vite: {
optimizeDeps: {
exclude: ["@resvg/resvg-js"]
}
},
adapter: netlify()
});
and here's the auth config
import CredentialsProvider from '@auth/core/providers/credentials'
export default {
providers: [
CredentialsProvider({
async authorize(credentials) {
const authResponse = await fetch("/api/protected/auth", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(credentials),
})
if (!authResponse.ok) {
return null
}
const user = await authResponse.json()
return user
},
}),
],
}
Is your config named 'auth.config.ts' or something else? If it's something else you need to define the path in the auth. Integration with the parameter 'configFile'
That was it!
Oh my I'm sorry! 😅 But thank you so much for the help, I had misread the readme! and named it [...auth].ts
If it's okay with yourself I may tweak the ReadMe a little bit and submit a PR just to clear the process up a little.
I'm glad I could help 😄 Yes please do so, I highly appreciate the community feedback :)
Sorry, I think I was too eager to close this.
After closing, I decided to test the authentication since I assumed it was working fine as I could launch the server. However, I encountered some issues when trying to get the login components to work. I kept getting a 404 error on the CSRF call.
Thinking that I might have made a mistake during the setup, I started fresh and followed the tutorial from otterlord . But I ended up encountering the same error mentioned at the beginning of the ticket. I suppose I must have confused the system, which is why the error was hidden initially.
The strange thing is that when I boot the project in something like Codespaces or GitPod and run it, it works fine. Even more peculiar, when I checked out TheOtterlord's astro-auth-example on my Windows machine, it also worked. So, I'm not sure if it's something to do with the combination of versions/packages I have or if there's another factor at play.
When I have some free time, I'll try starting a fresh project, but for now, I would like to reopen the ticket.
Using
astro add auth-astro
to add the auth to my project on Windows using the recommended process and base settings straight out of the box, then I get the following error.I presume it's the initial
\
as if I follow the path it does exist.I've tried to do some digging to figure out the root cause but I have been unable to get to figure it out.
My
Package.json
Please let me know any other information you'd require and I'll get them to you asap