Proxy Redirect with CORS issue, site not working?

Hi I have setup my application in netlify and this is the netlify.toml settings with the Proxy redirect masking.

[[redirects]]
from = “/*”
to = “https://go.myapplication.com/version-test/:splat
status = 200
force = true

[[headers]]
for = “/"
[headers.values]
Access-Control-Allow-Origin = "

However I am getting “…has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.”

So I cant login to my application. I know there is a couple of posts which I have tried, but still not working. Any Help ?

Hey @feltj

[[redirects]]
from = "/*"
to = "https://go.myapplication.com/version-test/:splat"
status = 200
force = true

This redirect is forcing all requests to the back-end application, with nothing served by Netlify. Is this your intention?

Are you deploying a front-end app (e.g. React, Next, etc.) to Netlify that you wish to connect to a back-end hosted elsewhere (e.g Heroku)?

Thank you for the reply.

Yes I have a backend with Bubble app and I want to deploy to Netlify, as I am trying to create a multi site with possibly of different domains name.

I am not sure if there is other solution, as I was trying to work it out using the proxy.

SPAs deployed to Netlify need a special redirect as mentioned in the History pushstate and single-page apps documentation.

Better to have a specific rewrite for the backend for example

[[redirects]]
  from = "/api/*"
  to = "https://api.somewhere.com/v1/:splat"
  status = 200

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200

where all requests to the /api path are routed to the backend. You can read a more detailed post here.

Hi, I did the changes and put *Access-Control-Allow-Origin = " * ” in the netlify.toml as well.

But i keep having the CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.” whichever I try.

Is it because Access-Control have to be deployed in the server side ?

Can you share the site this is occurring on?

Yes, I have pm you the site. Thank you/

From what I can tell, there is no Access-Control-Allow-Origin header on the remote server which is required.

1 Like

I see, thus adding Access-Control-Allow-Origin in netlify.toml won’t work ?

No, it is nothing to do with Netlify.

1 Like

I see. Thank you so much for the help.

Let me try if I add Access-Control-Allow-Origin in the server.

Another point I might raise it the redirect you are using. In your original post you say you are using

which means you are proxying all content to another site and serving nothing from Netlify.

Are you publishing any content to Netlify or only using Netlify to proxy to another site/service?

Currently using Netlify to proxy to another site/service.

Initially I publish an index.html with iframe in it of my application in netlify.
However, I have Safari issue with error of cookies as Safari by default discards cookies set in an iframe.

Currently looking for other solution such as the proxy, but now there is CORS issue. :sob:

I’m curious why you don’t configure the domain you are trying to proxy from directly on the service you are proxying to—an alias if you wish. Adding the appropriate DNS records and configuring the service to use the domain sounds like a much better method.

I am sorry I don’t understand. You mean getting a proxy server service as such ?

My current Bubble backend application can only set to 1 main domain while I have to split into many domains for different clients with different domains respectively. I thought I could just provide them the IP from netlify to my clients to set up their domains.
I came across Netlify through browsing where people use the redirect.

A better way to implement something on Netlify is to have a site to deploy which uses a proxy e.g.

[[redirects]]
  from = "/api/*"
  to = "https://api.somewhere.com/v1/:splat"
  status = 200

or function (especially if you wish to keep API keys secret), to access the backend API (that’s the A in JAMstack afterall.)

Simply using Netlify to proxy an entire site is a poor use of the service at best (have you read the Terms of Use Agreement by any chance?) Given the backend is running on Cloudflare you are proxying to another CDN—see [Support Guide] Why not proxy to Netlify? (though this is possiblly the reverse for you.)

In effect what you are doing is masking the URL of the backend. Some registrars (e.g. Namecheap) have URL Redirect Records which you can set as masked which is likely a better option.

1 Like

I see. I apologize I did not know about the use in the Terms.
I will look into the solution you provide and others.

I tried the Namecheap though, its using the iframe and it will have cookies issue in the Safari where cannot login.