N
Novu12mo ago
dr.really

CORS issue

Trying to get thing stood up in AWS, however I'm running into a CORS issue. I have the API running at https://novu.mydomain.com, and the web variant running at https://web-novu.internal.com. I have set the FRONT_BASE_URL environment to https://web-novu.internal.com/ and my NODE_ENV is production as per other CORS issues I found before creating this post. When I navigate to the login screen, and attempt to login, I get the CORS preflight error.
Access to XMLHttpRequest at 'https://novu.mydomain.com/v1/auth/login' from origin 'https://web-novu.internal.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Access to XMLHttpRequest at 'https://novu.mydomain.com/v1/auth/login' from origin 'https://web-novu.internal.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Currently running v0.15.0
28 Replies
Pawan Jain
Pawan Jain12mo ago
Thanks for detailed information in issue We will look into this
dr.really
dr.really12mo ago
Any update or eta on a resolution? Or should we just pull back the version to 0.13? @Support
Pawan Jain
Pawan Jain12mo ago
Hi @dr.really Unfortunately Sorry, I can't give you ETA for this. I would highly appreciate if someone from community can fix this Untill then you can switch back to previous version
dr.really
dr.really12mo ago
This is a pretty large breaking change for the latest version. I feel like this should take a priority to fix.
--
--12mo ago
Can you confirm that this error was not happening for you in v.0.13 deploying in the same way as it is no? Also how are you deploying the project to AWS: k8s, docker, manual deployments? Unfortunately we have experienced that most of the CORS problems are coming from misconfigurations by the users. 😕 We can't review individual configurations and deployments as it is out of our scope from the community solutions for self hosting, but we try our best to provide tips and potential solutions with the info provided.
dr.really
dr.really12mo ago
Morning @pablo.fernandez.otero I'm updating the task def now and will let you know shortly about v0.13 For more context, I am deploying on AWS EC2 fargate, I did put my task definition in the issue linked above, I can drop it here if you'd like @pablo.fernandez.otero quick question, the api, does it get it's CORS option from the FRONT_BASE_URL environment variable?
--
--12mo ago
Yes, that's right. It validates against that environment variable.
dr.really
dr.really12mo ago
Apologies, follow up question. This is the error that I'm getting: No 'Access-Control-Allow-Origin' header is present on the requested resource. When I attempt to login via the UI it throws that. If I login through the API directly via postman it works. Is there an additional environment variable I need to set for the UI?
--
--12mo ago
Could you show the cURL or request sent? As I mentioned before most of the CORS problems are coming from misconfigurations. Also calls from Postman are not browser calls (Postman is like a Backend to Backend call). CORS is a policy enabled by browsers. So that's the reason why in Postman it works.
--
--12mo ago
Another tip I can advise is to debug here https://github.com/novuhq/novu/blob/4b71ba025c44a422f6640da3a371a5fdb6470e2d/apps/api/src/bootstrap.ts#L149 what are the values set for the CORS policies, by debugging the values of corsOptions and comparing them to the configured values in the environment variables and the values provided in the requests from the Web app.
GitHub
novu/apps/api/src/bootstrap.ts at 4b71ba025c44a422f6640da3a371a5fdb...
The open-source notification infrastructure with fully functional embedded notification center - novu/apps/api/src/bootstrap.ts at 4b71ba025c44a422f6640da3a371a5fdb6470e2d · novuhq/novu
dr.really
dr.really12mo ago
Will do! I'm also reaching out to our cloud engineers to ensure that AWS WAF isn't doing something strange with the request
--
--12mo ago
That's an important point. If you have set up a firewall and it is blocking every request by default (it would make sense for security point of view) that might be affecting. Also any kind of service that can redirect the calls that might be striping out the headers from the call or modifying them, in case you have a complex set up.
dr.really
dr.really12mo ago
Alright, I just confirmed that if you change the NODE_ENV to test it works. I was able to login with no CORS issue That was on v0.14, trying 0.15 (no changes made to the firewall)
--
--12mo ago
That's a cheat and it is not recommended for production use.
dr.really
dr.really12mo ago
It's the only way thats working
--
--12mo ago
I can only advise that we, Novu, don't recommend that as a production solution because the security implications that disabling CORS imply.
dr.really
dr.really12mo ago
Totally understandable I'm trying different configurations to see which ones work, that's all 🙂 With the front base url, is it the full URL with https:// or just the novu.mydomain.com?
dr.really
dr.really12mo ago
also, strangely, v0.15 isn't picking up the REDIS_HOST env either
--
--12mo ago
This issue is caused by this: https://github.com/novuhq/novu/issues/3594#issuecomment-1592791709 Basically I guess you are setting right now NODE_ENV as dev we have the configuration set for our needs as we would expect people to set for their environment NODE_ENV as prod because we expect them to use a final version for all environments and not modify the code.
GitHub
[NV-2435] Feature: Create feature flag for IN_MEMORY_CLUSTER_MODE_E...
I'm submitting a... [] bug report feature request question about the decisions made in the repository [] question about how to use this project Summary I'm trying to run novu from the man...
dr.really
dr.really12mo ago
ah, that makes sense. Apologies if I'm being annoying with all of this. Just trying to figure it out that's all 🙂
--
--12mo ago
The requests are made always with the protocol so I suggest to add them. I am not sure if they would ever work without the protocol (the CORS) so I would go the safe bet of adding it. Also check the protocol is the same as the one enabled. No worries, happy to help. But as I mentioned before we don't give support for self hosted solutions though we try our best to point out to potential solutions.
dr.really
dr.really12mo ago
I finally figured out what was going on. First, AWS WAF was stripping the initial origin header, giving it instead the origin header of the application load balancer. Once I got the cloud engineers to get that stopped it started working properly and we successfully have v0.14 up and running! Once last question, we have IN_MEMORY_CLUSTER_MODE_ENABLED set to false, but for some reason the api keeps saying that inMemory is down, but this is only on 0.15. The 0.15 variant of the Web Socket and Worker services are running fine, just the API. Do we need to set another variable?
--
--12mo ago
No, is what I mentioned in the previous message: https://discord.com/channels/895029566685462578/1119075100394786956/1120347592702820373 You need to set NODE_ENV to production even in your non-production environments. If you set it to dev the .env.development config is set for our needs and there we are testing a Redis Cluster for usage for the Cache system. If you have set NODE_ENV to production let us know your config as there might be any problem happening.
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Novu_Bot
Novu_Bot12mo ago
@Sinan, you just advanced to level 1!
--
--12mo ago
@Sinan could you please reopen the support post you had open and we can discuss it there? I'd rather not have mixed conversations in this support post so it can be a good read for other users. 🙏
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View