Plugin API - Origin
If you had to had to build the logic for the API to at least accept one other URL to the allowed origins, where would you start? I'm struggling to understand where the plugin API is setting things up.
Edit: Just found PluginMiddleware in Headers. It should be this one right?
Solution:Jump to solution
why do you want to allow 2 origins anyway? If you're referring to both localhost and your production URL, you're supposed to separate your development and production environments to begin with. Never test/develop in production.
that said, yes you were on the right path of it being this middleware: https://github.com/sapphiredev/plugins/blob/main/packages/api/src/middlewares/headers.ts. As you can see you can just set
clientOptions.api.origin
to *
or whatever you want....8 Replies
Solution
why do you want to allow 2 origins anyway? If you're referring to both localhost and your production URL, you're supposed to separate your development and production environments to begin with. Never test/develop in production.
that said, yes you were on the right path of it being this middleware: https://github.com/sapphiredev/plugins/blob/main/packages/api/src/middlewares/headers.ts. As you can see you can just set
clientOptions.api.origin
to *
or whatever you want.I'm not refering to localhost, but staging. I already have 3 environments for the frontend and 2 for the backend, but would like to use the production bot for staging frontend as well. There is no breaking change currently that could happen with my use of the frontend.
Thanks!
Ah okay that makes sense then, and you're welcome
On a sidenote, i'm not sure what your staging environment looks like, but assuming it's a different bot why not make the frontend host on
beta.<yourwebsite>.<tld>
? (or staging, alpha, etc). Then each would have only 1 single origin. Just food for thought I guess.
sure there are no breaking changes right now but I'd say it's better to always just run 2 instances of the whole stackYeah that's true, for another setup I'm using 3 backend env and 3 frontends
1 local front + backend
1 staging front s3 bucket + backend aws instance
1 prod front s3 bucket+ backend aws instance.
But for this project I just wanted to be faster and it looks It will not be as fast as I thought hehe. Will probably stick to 3 different env 😛
alright
cool to see other people take staging environments so serious too
dont get that often in the bot dev circles
Hehe, testing things on prod is a bit like crossing your fingers and pray at every push lol
I think most people by now at least separate dev and prod but generally dont have a staging environment on top of that.