Vercel: A project file dynamically changing for each domain? - deployment

I am building a project on Vercel, deployed to multiple subdomains. The code should be 99% the same, but I need to have a different manifest.json for each subdomain.
Is there a way to make the manifest.json file dynamic, based on the subdomain the user visits?
I thought perhaps NextJS rewrites could help, but I am not sure how to use them.

I wasn't able to figure out how to serve /manifest.json, but at least I can return a JSON file from a NextJS Serverless function at api/manifest like so:
res.setHeader("Content-Type", "application/json;charset=utf-8");
return res.send(manifestJSON);

Related

Disable CDN through PowerShell

I built a React Typescript project in SharePoint.
I'm currently getting errors with how the CDN is serving up the content.
I want to disable CDN all together across all tenants.
Right now when I run:
Get-SPOTenantCdnEnabled -CdnType Public
I get back True
I just want a way to disable CDN. I found this article here but I'm having trouble with the command: https://learn.microsoft.com/en-us/powershell/module/sharepoint-online/remove-spotenantcdnorigin?view=sharepoint-ps
Remove-SPOTenantCdnOrigin -CdnType Public -OriginUrl sites/pubsite/siteassets/subfolder
I'm just not too sure what to put in the sites/pubsite/siteassets/subfolder section.
So all I'm trying to do is disable CDN on all tenants, I was following a tutorial and accidentally turned it on.
If you just want to disable the CDN option for a tenant without modifying the defined CDN providers, use Set-SPOTenantCdnEnabled:
Set-SPOTenantCdnEnabled -CdnType Both -Enable:$false

merge large existing web app into Sailjs site

I'm trying to merge large existing web app into sails.js. so I moved the folders into assets and build a custom route , 'GET /': '/assets/client/launch.html' and get 404 when I point my browser to http://localhost:1337/ as the / is correctly redirected to http://localhost:1337/assets/client/launch.html which produces the 404.
Now the file exists in the folder assets/client (and in .tmp), so I am thinking the Sails router is getting in the way.
I would leave the client (70K lines of JS) that generates all the UI dynamically and sailjs server that provides authentication separate and enable CORS but my customer wants client packaged with server. This type of operation is simple in frameworks like ASP.NET MVC but am wondering if Sails is up to the task.
Well, If everything you tried did not work out. There might be another solution ,
First of all since you are talking about sails app I am assuming other bundle must be sails as well ,
So here is what you do-
Change the port for another app that you want to attach to this.
Second whenever you want to go to page on another app simply redirect the client to another port ie
in html or esp put a href tag with different port.
<a href="localhost:PORT/route_to_file">
</a>
I got it working by placing my app into assets where we need to launch from assets/client/index.html as there would be too many dependencies to change. As I said above could not just add a route as Sails must getting in the way. However as in Chapter 3.2.2 of Sails in Action I generated a static asset npm install sails-generate-static --save. then I redirected to assets/client/index.html. As an aside that book is great and would highly recommend it.

Post csv content to Web Api

I have a c# console application which post .csv content to a web service. If I run my solution through VS, it runs perfectly fine but after deploying web service on IIS I keep getting Multiple Choice Status Code 300 error. Not sure how to resolve that. Any pointers would be appreciated.
Thanks
These are relatively simple but I cannot think of other possibilities based on your description.
One of my recent designs had a literal in the code that when I deployed it ended up using a different port which I had forgotten to change to a relative reference.
If not that then the other problem I had with it was because I used JSON to link to the web service. While it worked when viewing in VS when deployed my JSON reference was actually incorrect. specifically it had to do with code in my web.config file, which would be the app.config file for your console application. I had used the code
standardEndpoint helpEnabled="true" automaticFormatSelectionEnabled="false" crossDomainScriptAccessEnabled="true"
when I should have also added
defaultOutgoingResponseFormat="Json"
to make the code work

how do i redirect a specific path to another path in nginx?

I need to redirect a specific path:
mydomain.com/old-path/
to a new path, permanently:
mydomain.com/new-path/
i am using elgg software (elgg.org) and presently when someone navigates to the /old-path/ folder they view a page (rather than a folder listing) - thus no specific page name is used.
i tried the various methods of redirecting that can be found via google for nginx and so far none have had any effect. they mostly are either for a specific page or a directory, yet what i am doing, is, i suppose, technically neither a specific page or a directory..
anyone know how to achieve this?
thanks
You can use nginx HttpRewriteModule to do this.
rewrite ^/old-directory/(.*)$ /new-directory/$1 last;

Making GWT application crawlable by a search engine

I want to use the #! token to make my GWT application crawlable, as described here:
http://code.google.com/web/ajaxcrawling/
There is a GWT sample app available online that uses this, for example:
http://gwt.google.com/samples/Showcase/Showcase.html#!CwRadioButton
Will serve the following static webpage to the googlebot:
http://gwt.google.com/samples/Showcase/Showcase.html?_escaped_fragment_=CwRadioButton
I want my GWT app to do something similar. In short, I'd like to serve a different flavor of the page whenever the _escaped_fragment_ parameter is found in the URL.
What should I modify in order for the server to serve something else (a static page, or a page dynamically generated through a headless browser like HTML Unit)? I'm guessing it could be the web.xml file, but I'm not sure.
(Note: I thought of checking the Showcase app provided with the GWT SDK, but unfortunately it doesn't seem to support serving static files on _escaped_fragment_ and it doesn't use the #! token..)
If you want to use web.xml, then I think it won't work with a servlet-mapping, because the url-patterns ignore the get parameters. (Not 100% sure, if there is another way to make this possible.)
You could of course map Showcase.html to a servlet, and in that servlet decide what to do, based on the get parameter "_escaped_fragment_". But it's a little bit expensive to call a Servlet just to serve a static page for the majority of the requests (not too bad, but still. You could set cache headers, if you're sure that it doesn't change).
Or you could have an Apache or something in front of your server - but I understand, I wouldn't like to have to do that either. Maybe your JavaEE server (which one are you using BTW?) provides some mechanism for URL filtering before the request gets passed on to the web container - I'd like to know that, too!
Found my answer! The Showcase sample supporting crawlable hyperlinks is in the following branch:
http://code.google.com/p/google-web-toolkit/source/browse/branches/crawlability/samples/showcase/?r=7726
It defines a filter in the web.xml to redirect URLs with the _escaped_fragment_ token to the output of HTML Unit.