TomD
TomD
WWasp-lang
Created by TomD on 6/25/2024 in #đŸ™‹questions
use auth when requesting a custom api without the api wrapper
Thanks a lot !
14 replies
WWasp-lang
Created by TomD on 6/25/2024 in #đŸ™‹questions
use auth when requesting a custom api without the api wrapper
Indeed it's working ! I went the sessionId solution fow now to not change to axios but I will probably come back to your message and implement this clean solution if I have time !
14 replies
WWasp-lang
Created by TomD on 6/25/2024 in #đŸ™‹questions
use auth when requesting a custom api without the api wrapper
Ok thanks for the clarification, if I just switch to axios things should work ? I'll try this then. For the second solution with the JWT token, how can I access it to pass it in the header of my request ?
14 replies
WWasp-lang
Created by tomas.morales on 6/11/2024 in #đŸ™‹questions
manual deploy gcp
Thanks for the help, if someone ever has a problem to deploy it on GCP I'd be happy to help đŸ™‚
42 replies
WWasp-lang
Created by tomas.morales on 6/11/2024 in #đŸ™‹questions
manual deploy gcp
I tried for a few hours, I couldn't make it work for some edge case indeed.. So I rolled back to use the ugly URL path, if I want to go the clean way someday I'll settle for your recommandation with api.example.com
42 replies
WWasp-lang
Created by tomas.morales on 6/11/2024 in #đŸ™‹questions
manual deploy gcp
I'm trying to do something like:
export const redirectApi = (req: Request, res: Response) => {
console.log('old path', req.path);
const newPath = req.path.replace('/api', '');
console.log('new path', newPath);
res.redirect(newPath);
};
export const redirectApi = (req: Request, res: Response) => {
console.log('old path', req.path);
const newPath = req.path.replace('/api', '');
console.log('new path', newPath);
res.redirect(newPath);
};
With a new route in the main.wasp file:
api redirectApi {
fn: import { redirectApi } from "@src/server/apis.js",
httpRoute: (ALL, "/api/*")
}
api redirectApi {
fn: import { redirectApi } from "@src/server/apis.js",
httpRoute: (ALL, "/api/*")
}
42 replies
WWasp-lang
Created by tomas.morales on 6/11/2024 in #đŸ™‹questions
manual deploy gcp
I didn't with wasp, but for an old website with python fastAPI I went with this approach and I believe I did so I'm always precautious
42 replies
WWasp-lang
Created by tomas.morales on 6/11/2024 in #đŸ™‹questions
manual deploy gcp
Thanks for the brainstorming ! You are right with everything you said, the cleanest way is what you specified with an api.example.com I think. Unfortunately to do this in GCP you need to provision your own load balancer, then you can basically do whatever you want with it with any redirect to subdomains, url rewrite, etc.. I can do this but this cost a something like 5/10 e per month for the load balancer to be up and running, so I'm not going to go that way for now. I believe for clean production, this is definitely the way tho. But to come back to the the idea of having a prefix route, creating a custom api route under '"/api/**" that redirects to the same path but stripping the api would work ? When requesting https://backend-url.com/api/auth/me you would get redirected to https://backend-url.com/auth/me . This is not ideal but this is a minimal workaround I think
42 replies
WWasp-lang
Created by tomas.morales on 6/11/2024 in #đŸ™‹questions
manual deploy gcp
I've done this issue to document my journey to deploy it, I've not added the automatic redirect to have the front and back under the same domain name as I'm not completly sure on how to do it yet. https://github.com/wasp-lang/open-saas/issues/178
42 replies
WWasp-lang
Created by tomas.morales on 6/11/2024 in #đŸ™‹questions
manual deploy gcp
Okok, I see the use of nginx. I probably won't go that road and I'll try to find a workaround. Actually, GCP offers "cloud run" that can run the backend. Firebase, since it is a GCP product, offers the possibility to automatically redirect traffic of the website under a specific route, to the cloud run backend. See this documentation: https://firebase.google.com/docs/hosting/cloud-run?hl=en This make connecting the front and back really easy when you have full access on your code usually. Still there is some workaround I guess, I just need to find it
42 replies
WWasp-lang
Created by tomas.morales on 6/11/2024 in #đŸ™‹questions
manual deploy gcp
Do you know if there is a way to prefix every routes of the server ? Firebase offer the possibility to do some automatic route rewrites but I must add a prefix for some reason . So I can link the backend and frontend URL only if the backend route looks like this (any prefix would work but /api makes more sense). For example : https://my-super-exceptional-backend.run.app/auth/me --> https://my-super-exceptional-backend.run.app/api/auth/me https://my-super-exceptional-backend.run.app/auth/google/login --> https://my-super-exceptional-backend.run.app/api/auth/google/login etc...
42 replies
WWasp-lang
Created by tomas.morales on 6/11/2024 in #đŸ™‹questions
manual deploy gcp
It was fine I think. After running npm install && REACT_APP_API_URL=<url_to_wasp_backend> npm run build I deployed the content of .wasp/build/web-app/ and not .wasp/build/web-app/build so the frontend was obviously not what I expected
42 replies
WWasp-lang
Created by tomas.morales on 6/11/2024 in #đŸ™‹questions
manual deploy gcp
Ok I succeeded finally ! I was deploying the wrong folder, the documentation was clear I just ignored it for some reason đŸ˜¦
42 replies
WWasp-lang
Created by tomas.morales on 6/11/2024 in #đŸ™‹questions
manual deploy gcp
I actually solved the issue you've had with port 8080 on cloud run. The server by default was launching on port 3001, just setting the env variable "PORT" to 8080 solved the issue. Additionally you have to set the appropriate env variable, else the container will fail at the beginning and you'll likely get the same error, this is a bit hard to debug as the log is the same but the reason for it is different ! Nontheless I'm still having some issue, the server is up and running no problem but the frontend doesn't want to work. As I'm on GCP, I deployed the frontend using firebase hosting but I get a blank page. When looking at console logs I get:
index.tsx:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
saas-example-426610.firebaseapp.com/:33


GET https://saas-example-426610.firebaseapp.com/manifest.json 404 (Not Found)
manifest.json:2 Manifest: Line: 2, column: 1, Syntax error.
index.tsx:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
saas-example-426610.firebaseapp.com/:33


GET https://saas-example-426610.firebaseapp.com/manifest.json 404 (Not Found)
manifest.json:2 Manifest: Line: 2, column: 1, Syntax error.
I'm going to investigate, if I succeed and I have some time left I'm probably going to document it đŸ™‚
42 replies
WWasp-lang
Created by haarismian on 6/1/2024 in #đŸ™‹questions
I am getting a 403 on sendgrid sending locally
Thanks for asking, I believe all the process is 9/10 on doc from what I saw so thanks a lot for your effort on the doc. In the main.wasp there is a small comment here:
// NOTE: "Dummy" provider is just for local development purposes.
// Make sure to check the server logs for the email confirmation url (it will not be sent to an address)!
// Once you are ready for production, switch to e.g. "SendGrid" or "MailGun" providers. Check out https://docs.opensaas.sh/guides/email-sending/ .
// NOTE: "Dummy" provider is just for local development purposes.
// Make sure to check the server logs for the email confirmation url (it will not be sent to an address)!
// Once you are ready for production, switch to e.g. "SendGrid" or "MailGun" providers. Check out https://docs.opensaas.sh/guides/email-sending/ .
But for auth there is also the an email field, you could probably specify a similar comment to inform the user to change the email at this place too ?
10 replies
WWasp-lang
Created by haarismian on 6/1/2024 in #đŸ™‹questions
I am getting a 403 on sendgrid sending locally
Sorry for the inconvenience, actually I didn't update everything right. There were 2 places to change the "[email protected]" in the main.wasp file, I only changed the one from "emailSender" but not the one from "auth" !
10 replies
WWasp-lang
Created by haarismian on 6/1/2024 in #đŸ™‹questions
I am getting a 403 on sendgrid sending locally
Hello I have the same problem, I followed the documentation. I created a sendGrid account, I created a sender, verified the sender, copied an API key with maximum permission. I get "Failed to send email ResponseError: Forbidden" when I try to signin đŸ˜¦
10 replies