Netlify internal rewrite proxy to other react netlify site issue

Hello,
Note: … represents .com since I am limited on the # of links in a post.

Context
I currently have two netlify apps under a custom domain. api.cryptominerinfo…/ is my api that has some routes to serve some basic information. The other app is https://cryptominerinfoapidocs.netlify.app, which is based off of create-react-app.

Intentions
What I was wanting to do was have the route api.cryptominerinfo…/docs redirect to cryptominerinfoapidocs.netlify.app, since they are separate repos on github.

Issues
When I navigate to https://api.cryptominerinfo.com/docs, it redirects successfully as I can see “React app” in the site title. However, there is supposed to be text when I navigate and there is not. In the console the following error appears:

The resource from “api.cryptominerinfo.../static/js/main.b6e3b5a5.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

Maybe I have to define a MIME type when I redirect, but im not sure.

Files
netlify.toml in https://api.cryptominerinfo.com/ repo:

[build]
    functions = "functions"

[[redirects]]
  force = true
  from="/docs/*"
  to="https://cryptominerinfoapidocs.netlify.app"
  Access-Control-Allow-Origin = "*”
  status=200
[[redirects]]
    to="/.netlify/functions/api/:splat"
    from="/*"
    status=200

_redirects in https://api.cryptominerinfo.com/ repo:

/netlify-site/docs  https://https://cryptominerinfoapidocs.netlify.app/:splat  200

Note: my create-react-app does not have any netlify configuration. It is just a bare bones CRA application

Those are the same “app” in terms of Netlify. I think you are calling them 2 different apps because one of them is CRA and other is other Express, but all in all, it’s packaged as the same website (or app) on Netlify.

Based on your explanation, I am confused with your requirements. Why do you want to redirect the same site back to the same site?

I don’t know how this is possible as I’ve said, they’re on the same website! Netlify only supports deploying a site from a single repo.

What I’m assuming is, you want to deploy api.cryptominerinfo.com on a different site and redirect from that.

Thank you for taking time to reply. I think I know what you mean now,

I now currently have it set up to have my docs on api.cryptominerinfo.com. At route /api it redirects to apicryptominerinfo.netlify.app/.netlify/functions/api/, which hosts my api, but im wondering how to have it on the same url as explained below.

I was trying to have a repo hosted at https://api.cryptominerinfo.com and another repo at https://api.cryptominerinfo.com/docs. But now I assume that I have to put one repo at api.cryptominerinfo.com and handle routing that way?

Can I have an express backend (right now it is using lambda functions if that matters) and react frontend both deployed at api.cryptominerinfo.com? I think I remember reading that I could not do that, and I’d have to use Heroku, but im not sure how I could achieve the forntend and backend being on the same url with the other provider. Would you have any recommendations/solutions?

Frontend and backend on the same app is possible, you can check this repo for example:

Uses Express Backend using Netlify Functions with Vue frontend.

1 Like

I was able to get it working now, and that repository was very helpful. Thank you very much for your help.

1 Like