I'm relatively new to web development, and I've started using nano for coding, which feels like a huge upgrade from vi for me. I've been working on a project that pulls dynamic AJAX data from Microsoft 365 Power Automate Flows. I know, I know—Power Automate is notoriously slow and cumbersome, but it does a great job interacting with 365 documents if you're careful about error handling.
Recently, the URLs for the HTTP triggers in Power Automate got ridiculously long, over 255 characters. While that wasn't a problem for my web pages, it became an issue for a vendor callback that had strict URL length requirements. As a workaround, I thought about wrapping the Power Automate flows in an Azure Web App function.
Although I'm more comfortable with C, C++, and bash scripting than C#, I dove in. I set up an Azure trigger to clone requests to Power Automate and then cloned the results back to the original trigger response using Azure's function editor, which seemed pretty straightforward.
Everything seemed fine when I tested it with curl. The output was identical down to the hex level. But, the AJAX requests kept failing due to cross-origin resource sharing (CORS) issues. At first, I didn't include any CORS headers in my Power Automate outputs. After some trial and error, I added the appropriate headers in Azure, but that didn't resolve the problem.
After a considerable amount of frustration (even jokingly trying to reboot my mouse), I realized that using curl with the -H 'Origin' option would have shown me that Azure manages its own CORS headers that are independent of my C# code modifications. When I discovered this, I simply listed my domain in the application properties and removed the CORS headers I had added in my code. Everything started working perfectly. I hope this saves someone else from similar headaches!
3 Answers
Thanks for sharing your experience! It definitely helps to know that you're not alone in facing these kinds of issues.
Nice solution with the Azure function! Using curl and keeping to the Unix philosophy of single responsibilities is smart. You might also want to try using screen for editing multiple files in nano—could be a game changer!
Change more than one source file at a time? Are you crazy?! Just kidding, glad you got it working!
Welcome! It's always nice to share and help out others.